home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 1 / Cream of the Crop 1.iso / PROGRAM / MSC2BC.ARJ / CONVERT.TXT < prev    next >
Text File  |  1992-06-26  |  105KB  |  2,257 lines

  1. Microsoft C to Borland C++
  2. Conversion Guide
  3. BORLAND INTERNATIONAL, INC.  1800 GREEN HILLS ROAD
  4. P.O. BOX 660001, SCOTTS VALLEY, CA  95067-0001
  5.  
  6.  
  7. Copyright 1992 by Borland International. All rights
  8. reserved. All Borland products are trademarks or registered trademarks
  9. of Borland International, Inc. Other brand and product names are
  10. trademarks or registered trademarks of their respective holders.
  11.  
  12.  
  13.  
  14. If you're an experienced C or C++ programmer, but the Borland C++
  15. programming environment and tools are new to you, then you should read
  16. this section before you do anything else. We appreciate that you want
  17. to be up and running fast with a new piece of software, and we know
  18. that you want to spend as little time as possible reading manuals.
  19. However, the time that you spend reading this section will probably
  20. save you a lot of time later. Please read on.
  21.  
  22. Why Should You Use Borland C++, Anyway?
  23. You may have become accustomed to using Microsoft C over the years. If
  24. you were developing for the Windows environment in the past, Microsoft
  25. C and the SDK were the only game in town. And maybe you are a little
  26. skeptical that a newer product is superior to an old standby.
  27.  
  28. Compared to the Microsoft development environment, Borland C++ is a
  29. real time saver from the moment you install it until you have debugged
  30. your program. For most typical applications, a program compiled with
  31. Borland C++ executes faster than when compiled with Microsoft C. The
  32. Borland C++ environment provides you with more and better supporting
  33. tools than Microsoft's, tools that are easier to use and that save you
  34. many hours of time during your software development cycle. The time
  35. that you save enables you to develop richer and better software
  36. faster, and helps your company to remain competitive no matter what
  37. its line of business may be.
  38.  
  39. Let's cover these areas in greater depth.
  40.  
  41. Installation.
  42. There is one and only one installation program for Borland C++, and it
  43. sets up all of the Borland C++ tools and resources in a single highly
  44. integrated directory structure.
  45.  
  46. By contrast, you need to install several sets of software to be
  47. productive with Microsoft software development products. If some of
  48. your software is written in assembly language, you need to buy the
  49. Microsoft Assembler separately, and install it on your system. If you
  50. are writing software for Windows, first you must install Microsoft
  51. C6.0a, then pick and choose the tools, libraries, and header files
  52. from the Microsoft Windows SDK and decide where to install them. The
  53. installation of the Microsoft Windows SDK is a manual process with
  54. nothing to guide you or protect you from making a clerical error.
  55.  
  56. Once you have installed Borland C++, you will realize its built-in
  57. productivity benefits. Rather than setting up INCLUDE and LIB
  58. environment variables, you tell the Borland C++ Integrated Development
  59. Environment (IDE) where your include files and libraries are, and the
  60. IDE does all the rest.
  61.  
  62. PreCompiled Headers.
  63. By making good use of extended memory, using precompiled headers, and
  64. embodying other advanced compiler technology, Borland C++ compiles
  65. programs lightning fast even when all of the code optimization options
  66. and warning messages are enabled.
  67.  
  68. In a typical comparison of compilation speeds MAKEing a widely
  69. distributed Windows application of moderate size, Borland C++ produced
  70. an .EXE file in 46 seconds while the Microsoft tools did it in 146
  71. seconds, over three times as long. The program consisted of 12 C
  72. modules that contained 11000 source lines and 3 assembly language
  73. modules totaling 1000 lines plus all of the required header and
  74. include files. All possible compiler optimizations were enabled for
  75. this comparison. The test PC was a 33MHz 80486 with 16MB of memory and
  76. a SCSI hard disk with a 12 millisecond seek time.
  77.  
  78.  
  79. Integrated Environments.
  80. The Borland C++ IDE is quicker than PWB, which swaps to disk rather
  81. than using expanded or extended memory. It is much quicker and easier
  82. to edit several source files at once with the IDE.
  83.  
  84. Turbo C++ for Windows is a complete Windows-based system that allows
  85. you to edit, compile, test and debug Windows applications while
  86. remaining entirely within the Microsoft Windows environment. The Turbo
  87. C++ for Windows program editor has a contemporary SpeedBar for
  88. point-and-click action on common editing functions. Borland C++
  89. project files are interchangeable between Turbo C++ for Windows and
  90. the IDE, allowing you transparent use of the environment that suits
  91. your needs at a given moment.
  92.  
  93.  
  94. Debugging.
  95. The Turbo Debugger (TD) user interface is more intuitive to use than
  96. CodeView's, which retains many of the artifacts of its SYMDEB command-
  97. oriented predecessor. TD has commands to search memory for
  98. instructions or data elements, useful for debugging programs without
  99. source code or sometimes even with the source code. TD can be loaded
  100. resident to debug Terminate-and-Stay-Resident (TSR) programs. You can
  101. debug a program running in one PC remotely from another PC in cases
  102. where the run-time environment of a target program requires the
  103. maximum amount of available memory. Remote debugging with TD is
  104. possible via either a serial port or across a local area network
  105. (LAN). TD has companion driver modules which enable hardware-level
  106. debugging using the 386 debug registers.
  107.  
  108. Turbo Debugger for Windows runs inside Windows and allows you to debug
  109. Windows programs using a system with only a single monitor. When
  110. invoked, it saves the Windows screen context, displays debugging info,
  111. then switches back to Windows. CodeView requires two monitors for
  112. debugging, typically a color monitor for Windows and a monochrome
  113. monitor to display debugging info. CodeView has none of the other
  114. features above, though in some cases an expensive add-on product
  115. provides them.
  116.  
  117. Optimizations.
  118. Borland C++ gives you greater control over how the compiler optimizes
  119. your program with 13 independent classes of code optimizations. You
  120. can select the best combination of optimizations for your application,
  121. trading off execution speed and program size. Microsoft has just as
  122. many optimizations, but it is often not clear whether or not they
  123. overlap one another until you have experimented with the various
  124. choices.
  125.  
  126. Borland C++ provides in-line code generation for 19 frequently used C
  127. functions, Microsoft C for an indeterminate number. An in-line
  128. function often generates more code than a function call does, but it
  129. executes much faster than library function calls, especially on 386
  130. and 486 PCs with CPU cache memory.
  131.  
  132. Ansi Standard.
  133. Borland C++ is fully compliant with the ANSI C specification and
  134. incorporates the latest C++ 3.0 draft specification. Compiling with
  135. Borland C++ gives you extensive warning diagnostics, many of which
  136. tell you things about your program that even a commercial LINT program
  137. will not. Using these diagnostics, you can spot a problem area and
  138. change your program before debugging it, often avoiding long debugging
  139. sessions.
  140.  
  141.  
  142. Development Tools.
  143. Borland C++ is a complete development environment that includes many
  144. productivity tools which are not part of Microsoft C. If you ever want
  145. to search a group of source files to find occurrences of the same or
  146. similar strings of text such as variable or function names, the
  147. Borland C++ UNIX-style GREP program will do the job.
  148.  
  149.  
  150.  
  151. Resource Workshop
  152. For Windows development, the Resource Workshop is a single one-stop
  153. utility that integrates into a coherent hierarchy all of the Windows
  154. resources for a program, and allows you to conveniently edit, add, or
  155. delete any Windows resource from your program. It even allows you to
  156. edit the resources in an .EXE version of a program, a feature that is
  157. extremely useful for creating national language versions and for doing
  158. special customizations.
  159.  
  160.  
  161.  
  162. Turbo Profiler
  163. The Turbo Profiler allows you to profile Windows and non-Windows
  164. programs alike, and to isolate time-consuming hot spots in the code. 
  165. It measures the exact amount of time spent by your application on a
  166. function-by-function basis, or for each single statement executed by
  167. your program.
  168.  
  169.  
  170.  
  171. Other tools
  172. The H2ASH utility generates assembly language structures from C or C++
  173. header files, allowing you to easily keep C and assembly modules in
  174. sync. The TOUCH utility updates the file system date for a file or a
  175. set of files, so you can easily trigger an operation across a group of
  176. files such as a file backup or a program make. The OBJXREF program
  177. generates a cross-reference of global functions and variables used
  178. within object files and libraries, so you can see at a glance the
  179. relationship between function definitions and calls or among usages of
  180. global variables.
  181.  
  182.  
  183. Class Libraries.
  184. The Object Windows Library (OWL) is a C++ class library containing the
  185. classes used to program user interfaces for Windows applications.
  186. Turbo Vision is a similar library for DOS-based applications. Finally,
  187. the Borland C++ class libraries consist of reusable software to manage
  188. many objects used every day by programmers: sorted arrays, btree
  189. structures, linked lists, queues, hash tables, stacks, strings, and
  190. the PC hardware timer. Borland C++ includes the source code for most
  191. of these libraries, so that if you need to better understand how a
  192. function works, or if you want to derive a similar function, you can
  193. readily do so.
  194.  
  195. These are the many reasons why you should use Borland C++. As you use
  196. it more, you will surely find some more reasons yourself.
  197.  
  198.  
  199. Here is a summary to give you a quick start in getting your Microsoft
  200. C program running with Borland C++.
  201.  
  202. 1) Make sure your programs compile and run correctly with Microsoft C.
  203. There is no need to confuse things by converting programs that do not
  204. already work. If you do so, and something goes wrong, you won't know
  205. whether there was a bug in the original program, or the problem arose
  206. during the conversion process.
  207.  
  208. 2) Start up the Borland C++ IDE (Integrated Development Environment) and
  209. open a new project, giving it the same name as your compiled program.
  210.  
  211. 3) Select Borland C++ Keywords in the Options|Compiler|Source menu item
  212. of the IDE.  This option tells the compiler to recognize the Borland
  213. C++ extension keywords, including near, far, huge, asm, cdecl, pascal,
  214. interrupt, _es, _export, _ds, _cs, _ss, and the register
  215. pseudovariables.
  216.  
  217. 4) Now, add to the project the names of all of the C source (.C) files
  218. and .ASM modules for any assembly language functions you may have. If
  219. you are writing a program for the Windows environment, add .RC and
  220. .DEF files to the project as well. The Borland C++ IDE automatically
  221. keeps track of the other dependencies involving .H header files, .BMP
  222. bitmap files, .ICO icon files, .CUR cursor files, and assembly
  223. language include files.
  224.  
  225. 5) Turn on all warnings with the Options|Compiler|Messages menu item or
  226. with the -w command line option.
  227.  
  228. 6) Compile each module without any optimizations enabled.
  229.  
  230. 7) Any compiler warnings generated by Borland C++ will alert you to
  231. potential pitfalls. These catch many subtle programming errors
  232. otherwise not found until you debug your program. Try to figure out
  233. why the warning was generated. You might try to add ANSI function
  234. prototypes and explicit typecasts whenever you are in doubt about the
  235. correctness of the executable program.
  236.  
  237. 8) If you have any C-callable functions written in assembly language,
  238. refer to the brief discussion later on about C functions written in
  239. assembly language.
  240.  
  241. 9) Test your program, referring to the information and the sample
  242. programs in the following sections. They explain and illustrate the
  243. differences between Microsoft C and Borland C++ in detail.
  244.  
  245. 10) Finally, when your program is fully operational, recompile it with the
  246. required code optimizations enabled, and test again.
  247.  
  248. 11) If you want to compile your program from the command line rather than
  249. with the Borland C++ IDE, generate a Borland make file with the
  250. PRJ2MAK utility.
  251.  
  252.  
  253. This set of steps is not exhaustive and it does not cover every
  254. possibility that might arise when converting Microsoft C programs, but
  255. it is a reasonably complete set of guidelines for you to follow.
  256.  
  257. Compatibility
  258.  
  259. Borland C++ supports the same set of keywords as Microsoft C 5.1 with
  260. the exception of fortran. Borland C++ also supports the same set of
  261. keywords as Microsoft C 6.0 with the exception of:
  262.  
  263.    -_based, _self, and _segname, because Borland C++ does not support
  264.      based pointers
  265.  
  266.     - Borland C++'s keyword _seg is the equivalent of the Microsoft keyword
  267.      _segment
  268.  
  269. _emit; Borland C++ uses the pseudofunction _ _emit_ _, because this
  270. style allows addresses of variables to be given as arguments, and
  271. allows multiple bytes to be output; _emit, by contrast, works like an
  272. assembly DB, allowing one immediate byte to be output. If your program
  273. uses the Microsoft _emit, add the following statement to your program
  274. after the including dos.h:
  275.  
  276. #define _emit(b) _ _emit_ _ (b)
  277.  
  278. _fortran; use the _pascal calling convention instead
  279.  
  280. Borland C++ provides _cs, _ds, _es, and _ss pointer types. See the
  281. section "Mixed model programming: Addressing modifiers" in the Borland
  282. C++ Programmers Guide for more information.
  283.  
  284. If your program uses the fortran calling convention for functions, you
  285. can use the pascal calling convention instead. If you have many
  286. fortran functions in a source module, you might find it convenient to
  287. add the following statement just before all of the header declarations
  288. in your source code module:
  289.  
  290. #define fortran _pascal
  291.  
  292. However, pay attention to the differences between Microsoft C and
  293. Borland C++ in the scheme for passing floating point arguments,
  294. especially if your fortran function is written in assembly language.
  295.  
  296. The __MSC macro
  297. If your Microsoft C program uses the DOSERROR structure, then, and
  298. only then, you need to add the definition of the _ _MSC macro to your
  299. program to preserve compatibility with the Microsoft variable names
  300. used within DOSERROR.  In previous versions of Borland C++, you needed
  301. to incorporate the _ _MSC macro to use many Microsoft C DOS and BIOS
  302. functions. The statement
  303.  
  304. #define _ _MSC
  305. needs to appear before the statement
  306.  
  307. #include <dos.h>
  308.  
  309. to use the Microsoft DOSERROR variable names.
  310.  
  311. The Header Files
  312. You can use either the old Microsoft header file name or the
  313. equivalent Borland C++ header file name according to the following
  314. table:
  315.  
  316.     Original        Alias
  317.     alloc.h            malloc.h
  318.     dir.h              direct.h
  319.     mem.h              memory.h
  320.  
  321. A Memory Model Overview
  322. Although the same names are used for the six standard memory models,
  323. there are some fairly significant differences in memory allocation for
  324. the large data models in the standard memory configurations.
  325.  
  326. In Microsoft C, all large data models (compact, large, and huge) have a
  327. default NEAR data segment to which DS is maintained. Data is allocated
  328. in this data segment if the data size falls below a certain threshold,
  329. or in a far data segment otherwise. You can set the threshold value with
  330. the /Gtn option, where n is a byte value. The default threshold is
  331. 32,767. If /Gt is given but n is not specified, the default is 256.
  332.  
  333. In the other three memory models (tiny, small, and medium) under
  334. Microsoft C, both a near and a far heap are maintained.
  335.  
  336. In Borland C++, the large and compact models but not the huge model have
  337. a default NEAR data segment to which DS is maintained. All static data
  338. is allocated to this segment by default, limiting the total static data
  339. in the program to 64K, but making all external data references near.
  340.  
  341. In Microsoft's version of the huge memory model, a default data segment
  342. for the entire program is maintained which limits total near data to
  343. 64K. No limit is imposed on array sizes since all extern arrays are
  344. treated as huge (_huge).
  345.  
  346. In Borland C++'s huge memory model, each module has its own data
  347. segment. The data segment is loaded on function entry. All data defined
  348. in a module is referenced as near data and all extern data references
  349. are far. The huge model is limited to 64K of near data in each module.
  350.  
  351. A command line compiler option, -Fs, and integrated environment dialog,
  352. Options|Compiler, are available to allow the Borland C++ compiler to
  353. assume that DS is equal to SS in all memory models. You can use it when
  354. porting code originally written for Microsoft C that makes the stack
  355. part of the data segment.  When you specify this option, the compiler
  356. will link in an alternate startup module (C0Fx.OBJ) that will place the
  357. stack in the data segment.  Usually the compiler assumes that SS is
  358. equal to DS in the small, tiny and medium memory models (except for
  359. DLLs).
  360.  
  361. The details of memory management functions, and the differences between
  362. Microsoft C and Borland C++ in this area, are covered in the discussion
  363. of MALLOC.H below and in the following section entitled "Converting
  364. Microsoft DOS Memory Management Functions".
  365.  
  366. Constants and COMDEFs
  367. Defining data in the header files in your program can cause duplicate
  368. symbol errors at link time if the same header file is compiled into
  369. multiple modules.  Microsoft C generates communal variable (COMDEF)
  370. records in the .OBJ files for global data allowing the linker to map
  371. duplicate global data to the same storage location.
  372.  
  373. Borland C++ also supports COMDEF generation with the -Fc command-line
  374. option. -Fc tells the compiler to generates COMDEFs for global "C"
  375. variables that are not initialized and not declared as static or extern.
  376. So long as a given variable doesn't need to be initialized to a nonzero
  377. value, you don't need to include a definition for it in any of the
  378. source files.
  379.  
  380.  
  381.                       Some Conversion Hints
  382.  
  383. Use Portable Functions
  384.  
  385. Portable functions are those compatible with many different compilers
  386. and machines. Generally they are ANSI standard functions. Whenever
  387. possible, use only functions from the ANSI standard library (for
  388. /example, use time instead of gettime). The portability boxes in the
  389. Borland C++ Library Reference Manual will tell you if a function is ANSI
  390. standard.
  391.  
  392. If you must use a function that's not in the ANSI standard library, use
  393. a Unix-compatible function, if possible (for example, use chmod instead
  394. of _chmod). Again, the portability boxes in the Borland C++ Library
  395. Reference Manual will tell you if a function is available on Unix
  396. machines.
  397.  
  398. Use Function Prototypes
  399.  
  400. Write function prototypes for all functions that do not yet have them.
  401. Function prototyping was added to the ANSI C standard to help you find
  402. subtle logic errors quickly. But you have to use function prototypes for
  403. them to help you.
  404.  
  405.  
  406. Avoid Machine Dependencies
  407.  
  408. Avoid the use of bit fields and code that depends on word size,
  409. structure alignment or memory model. For example, Borland C++ defines
  410. ints to be 16 bits wide, but a 32-bit C++ compiler would define 32-bit
  411. wide ints.
  412.  
  413. Use ANSI standard manifest constants to refer to the various values and
  414. arguments used by standard C functions. More generally, use manifest
  415. constants to define constant values rather than sprinkling your program
  416. with hard-coded "magic numbers".
  417.  
  418. DOSERROR
  419. If you use the DOSERROR structure in a source module, insert the
  420. preprocessor statement
  421.  #define _ _MSC
  422.  before dos.h is included.
  423.  
  424. /STACK Linker Option
  425. If you were using the link option /STACK:n in your Microsoft C
  426. application, initialize the global variable _stklen with the appropriate
  427. stack size.
  428.  
  429.  
  430.             Source Program Conversion - Header by Header
  431.  
  432. Borland C++ provides far-reaching source language compatibility for DOS
  433. and Windows programs written with Microsoft C Version 6.0a. The
  434. exceptions consist of nonstandard functions and manifest constants that
  435. are not often used. As a result, you should be able to compile almost
  436. any Microsoft C6.0a source program with few source code changes, if any,
  437. and have it working quickly with Borland C++.
  438.  
  439. The number of exceptions where you need to make source code changes are
  440. listed below in alphabetical order arranged by Microsoft C header file
  441. name, along with suggestions and examples for how to treat them.  If a
  442. Microsoft C header file is not listed here, this means that there are no
  443. known issues with its compatibility between Microsoft C6.0a and Borland
  444. C++. Eighteen of the 33 header files shipped with Microsoft C6.0a and
  445. the Microsoft Windows Software Development Kit (SDK) are fully
  446. compatible with Borland C++.
  447.  
  448. The functional areas of C that require the greatest number of changes
  449. are memory management and graphics. If your Microsoft C6.0a programs
  450. make extensive use of functions in these areas, refer to the more
  451. lengthy sections that follow. They compare the Borland C++ and Microsoft
  452. C approaches, contain programs that guide you through a successful
  453. conversion, and compare functionally equivalent Microsoft C programs
  454. side by side.
  455.  
  456. CTYPE.H
  457. The manifest constants defined in the header files and used in the
  458. various ctype functions are different between MSC6.0 and Borland C++. As
  459. long as you use the portable ctype macros, this should present no issue.
  460. If your program uses only the portable ctype macros, rather than
  461. referring to the ctype manifest constants, it will behave the same with
  462. either compiler.
  463.  
  464. If your program does refer directly to the Microsoft C ctype manifest
  465. constants, add any of the following #defines as appropriate: 
  466.  
  467. #define    _UPPER    _IS_UPP    /* upper case letter */
  468. #define    _LOWER    _IS_LOW    /* lower case letter */
  469. #define    _DIGIT    _IS_DIG    /* digit[0-9] */
  470. #define    _SPACE    _IS_SP    /* tab, carriage return, newline, */
  471.             /* vertical tab or form feed */
  472. #define    _PUNCT    _IS_PUN    /* punctuation character */
  473. #define    _CONTROL    _IS_CTL    /* control character */
  474. #define    _HEX    _IS_HEX    /* hexadecimal digit */
  475.  
  476. Borland C++ has no equivalent for the _BLANK manifest constant used
  477. within the Microsoft C version of the isprint macro. The following
  478. program shows how to define and use a portable isblank macro to test for
  479. a blank space. This is much better than using _BLANK.
  480.  
  481. /* ISBLANK.C illustrates use of the portable character classification
  482.  * function isblank.
  483.  */
  484.  
  485. #include <ctype.h>
  486. #include <stdio.h>
  487. #define isblank(_c)  isprint(_c) && !isgraph(_c)
  488.  
  489. void main()
  490. {
  491.     int ch;
  492.  
  493.     /* Display the blank character. */
  494.     for( ch = 0; ch < 256; ch++ )
  495.     {
  496.     if (isblank(ch))
  497.     printf ( "The value 0x%.2x is a blank space.\n", ch );
  498.     }
  499. }
  500.  
  501. When compiled and run with either compiler, ISBLANK.C displays one line
  502. of text, "The value 0x20 is a blank space."
  503.  
  504. The Microsoft C6.0a ctype header also contains two undocumented macros
  505. useful primarily for the language syntax checking done by a C compiler:
  506. iscsym and iscsymf.
  507.  
  508. DOS.H
  509. If your Microsoft C6.0a program uses the dosexterror function and its
  510. associated DOSERROR structure and variable names, add the following
  511. statement to your program to define the DOSERROR structure according to
  512. Microsoft C conventions:
  513.  #define __MSC
  514.  
  515.  
  516. ERRNO.H
  517. The numeric values of the manifest constants for many of the error codes
  518. returned in the global variable errno differ between the Borland C++
  519. errno.h and its Microsoft C6.0a counterpart. Many of these manifest
  520. constants are present to provide compatibility with UNIX. As long as
  521. your program refers to error codes using the manifest constants
  522. themselves, rather than any numeric values, it will behave the same with
  523. either compiler. The following pair of short code fragments illustrates
  524. this point, and underscores the role of standard C manifest constants in
  525. making programs portable: 
  526.  
  527. /* ERRNO.H Example 1 - This example IS NOT portable */
  528.   int ThisError;
  529.   ThisError = errno;
  530.   if (ThisError == 7)
  531.     /* When reporting that an argument list that is too long,
  532.        the Microsoft C run-time library assigns value of 7
  533.        to the error code, while Borland C++3.0 run-time
  534.        library assigns a value  of 20. */
  535.     printf("Arg list too long");
  536.  
  537.  
  538. /* ERRNO.H Example 2 - This example IS portable */
  539.   int ThisError;
  540.   ThisError = errno;
  541.   if (ThisError == E2BIG)
  542.     /* When reporting that an argument list that is too long,
  543.        the manifest constant value E2BIG is returned by both
  544.        Microsoft C6.0a and Borland C++3.0. */
  545.     printf("Arg list too long");
  546.  
  547. FCNTL.H
  548. The Borland C++ header file does not define the older UNIX manifest
  549. constant O_RAW. If your Microsoft C program uses it, add the following
  550. statement to your program after including fcntl.h:
  551.  
  552. #define  O_RAW  O_BINARY
  553.  
  554.  
  555. FLOAT.H
  556. Between Borland C++ and Microsoft C6.0a, there are very minor
  557. differences in the values of some of the double precision (DBL_...) and
  558. floating point (FLT_...) manifest constants that specify the limits of
  559. computations. If your program explicitly references any of these
  560. constants, make extra sure to verify that it produces the expected
  561. results with Borland C++.
  562.  
  563. Also, some 8087/80287 status word subconditions (SW_...) and floating
  564. point error signals (FPE_...) are defined as manifest constants in the
  565. Microsoft C header, but not in the Borland C++ header. If your program
  566. uses any of these manifest constants, add them to your program source
  567. code with #defines.
  568.  
  569.  
  570. GRAPH.H
  571. The Borland C++ Borland Graphical Interface (GRAPHICS.H) is quite
  572. different from the low-level graphics library supplied with Microsoft C,
  573. although the respective functions show a general one-to-one
  574. correspondence. If your programs currently use Microsoft's GRAPH.H, see
  575. the following section entitled "Converting Microsoft DOS Graphics
  576. Functions" for more details and examples.
  577.  
  578.  
  579. LOCALE.H
  580. The manifest constants LC_MIN and LC_MAX are not in the Borland C++
  581. locale.h header file. If you use them in your Microsoft C6.0a program,
  582. add the following prior to compiling with Borland C++:
  583.  
  584. #define  LC_MIN  LC_ALL
  585. define  LC_MAX  LC_TIME
  586.  
  587.  
  588. MALLOC.H
  589. The Borland C++ memory management functions differ somewhat from the
  590. memory management that is part of Microsoft C6.0a. If your programs
  591. currently use Microsoft's MALLOC.H, see the section entitled "Converting
  592. Microsoft DOS Memory Management Functions" for a comparison between the
  593. two memory management facilities and some practical examples of
  594. Microsoft C6.0a programs, before and after conversion to Borland C++.
  595.  
  596. If your programs rigorously use only the ANSI standard C memory
  597. allocation functions, it is unlikely that you will have any difficulty
  598. recompiling and running your programs with Borland C++. If you use the
  599. DOS-specific memory management functions provided by Microsoft C, then
  600. you will have to take some care in converting your programs.
  601.  
  602.  
  603. MATH.H
  604. Older versions of Microsoft C used a 6-byte floating point format that
  605. predated the standard IEEE format. Microsoft C6.0a provides a set of
  606. functions to convert data between Microsoft's old format and the IEEE
  607. format. These functions are typically used for converting data files
  608. from one format to the other. Borland C++ does not support the
  609. proprietary Microsoft floating point format. Use the standard IEEE
  610. format instead, and convert all of your data files to IEEE format.
  611.  
  612. Borland C++ does not provide the Bessel functions of the first and
  613. second kinds which are available in the Microsoft C6.0a run-time
  614. library: j0, j1, jn, y0, y1, yn, _j0l, _j1l, _jnl, _y0l, _y1l, and _ynl.
  615.  
  616. PGCHART.H
  617. Borland C++ does not include functions to display presentation graphics,
  618. a library added to Microsoft C with Version 6.0a.
  619.  
  620. PROCESS.H
  621. The Microsoft 6.0a functions wait is not in the Borland C++ header file.
  622. wait is a function available under UNIX.
  623.  
  624. SIGNAL.H
  625. The Borland C++ header file does not define SIGUSR1, SIGUSR2, and
  626. SIGUSR3, manifest constants for user signals contained in Microsoft
  627. C6.0a. If your program uses them, you need to define them yourself prior
  628. to compiling with Borland C++.
  629.  
  630. STDDEF.H
  631. The Borland C++ header file does not define the errno variable, as does
  632. Microsoft C6.0a. Instead the function prototype for errno is in
  633. Borland's errno.h, so add the following to your program:
  634.  
  635. #include <errno.h>
  636.  
  637. The function prototype for errno is also compiled conditionally by the
  638. dos.h and stdlib.h headers.
  639.  
  640.  
  641. STDIO.H
  642. If your program uses the high-level functions defined in this header
  643. file, your Microsoft C6.0a programs will compile and run with no
  644. changes. You need to be aware of a few things, however, if your program
  645. accesses any of the low-level elements defined in the Microsoft stdio.h
  646. header:
  647.  
  648. The Microsoft manifest constant, _NFILE, defines the maximum number of
  649. files that your program can have open at one time. Replace all
  650. references to _NFILE with references to the Borland C++ equivalent,
  651. FOPEN_MAX. Better still, add the following statement to your program
  652. after #include'ing stdio.h:
  653.  #define  _NFILE  FOPEN_MAX
  654.  
  655. If your program does the low-level stream I/O table manipulations
  656. typically found in older K&R-style C programs, then all references to
  657. the Microsoft C6.0a array, _iob[], need to refer instead to the Borland
  658. C++ array, stream[]. The simplest solution is to add the following
  659. statement to your program:
  660. #define  _iob  stream
  661.  
  662. The Microsoft C high-level macros getc and putc use the undocumented
  663. low-level _filbuf and _flsbuf functions, respectively.  As long as your
  664. programs use only high-level portable stream I/O functions, this is not
  665. a problem.
  666.  
  667. STDLIB.H
  668. If your program uses the function perror defined in the Microsoft C6.0a
  669. version of stdlib.h, add the following statement which adds the function
  670. prototype definition for the Borland C++ perror:
  671. #include <stdio.h>
  672. Note that the ANSI standard defines the perror function in STDIO.H and
  673. not STDLIB.H.
  674.  
  675. If your program uses the proprietary Microsoft function, onexit, replace
  676. all occurrences with the ANSI standard function, atexit. The easiest way
  677. to do this is with a single statement that makes the substitution with
  678. the C macro preprocessor:
  679. #define  onexit  atexit
  680.  
  681. TIME.H
  682. The manifest constants CLOCKS_PER_SEC and CLK_TCK have different values
  683. for Microsoft C6.0a and Borland C++. If you use the defined macros then
  684. no source code change is required. If your program depends on the
  685. specific value, either redefine them with the Microsoft C values, or
  686. change your program to use the Borland C++ values.
  687.  
  688.  
  689.  
  690.  
  691.          Assembly Language Functions Called by C Programs
  692.  
  693.  
  694. The conventions for passing arguments to functions on the stack are
  695. compatible between Borland C++ and Microsoft C6.0a for equivalent memory
  696. models (tiny, small, medium, large, compact, huge), and equivalent
  697. function types (near, far, cdecl, pascal, or _farcall). But there are
  698. some differences in the handling of return values by the compilers and
  699. these may require changes to your assembly language functions. These
  700. details are important for assembly language functions, but somewhat
  701. transparent for functions written in C. When your C function and your
  702. calling program are written, the Microsoft C and Borland C++ compilers
  703. adjust automatically for these differences in handling return values.
  704.  
  705. Structures Returned By Value
  706.  
  707. In a Microsoft C function declared with _cdecl, the function returns a
  708. pointer to a static location. This static location is created on a
  709. per-function basis. For a function declared with _pascal, the calling
  710. program allocates space on the stack for the return value. The calling
  711. program passes the address of the return value in a hidden argument to
  712. the function.
  713.  
  714. Borland C++ returns 1-byte structures in AL, 2-byte structures in AX and
  715. 4-byte structures in AX and DX. For 3-byte structures and structures
  716. larger than 4-bytes, the compiler passes a hidden argument (a far
  717. pointer) to the function that tells the function where to return the
  718. structure.
  719.  
  720. Integer Return Values.
  721. Microsoft C and Borland C++ are compatible in their conventions for
  722. returning simple integer variables. They return 1-byte variables (char)
  723. in AL, 2-byte variables (int, short, and near) in AX and 4-byte
  724. variables (long and far) in AX and DX.
  725.  
  726. Floating-Point Return Values.
  727. In Microsoft C, _cdecl causes float and double values to be returned in
  728. the _ _fac (floating point accumulator) global variable. Long doubles
  729. are returned on the NDP stack. _fastcall causes floating point types to
  730. be returned on the NDP stack. _pascal causes the calling program to
  731. allocate space on the stack and pass an address to the function. The
  732. function stores the return value and returns the address.
  733.  
  734. In Borland C++, floating point values are always returned on the NDP
  735. stack.
  736.  
  737. Rules for EXTERNs and External Symbols
  738. Borland C++ applies different rules than Microsoft C6.0a for generating
  739. external symbols for the Turbo Linker, depending on whether the function
  740. type is cdecl (default) or pascal. For cdecl functions, the rule is C
  741. function_name --> _function_name, i.e. function name retains its case
  742. and the underbar character is prefixed to it. For pascal functions, the
  743. rule is C function_name --> FUNCTION_NAME, i.e. function name simply
  744. transformed to upper case. In general, you would use pascal functions
  745. only in Windows programs.
  746.  
  747. The following set of changes to your assembly language source code
  748. should deal with many compatibility issues between Borland C++ and
  749. Microsoft C: (See the Turbo Assembler User's Guide and Programmer's
  750. Guide for more information.)
  751.  
  752. 1. Add the following directives at the beginning of your program to tell
  753. the Turbo Assembler (TASM) how to deal with Microsoft assembler (MASM)
  754. compatibility: 
  755.  
  756.     ifdef    ??Version    ; defined only by TASM
  757.     MASM51        ; MASM 5.1 compatibility
  758.     QUIRKS        ; assemble with MASM quirks
  759.     endif
  760.  
  761. 2. If your functions written in assembly language use the MASM .MODEL 
  762. directive for standard segmentation, then your functions will take the 
  763. form:  (The TASM MODEL directive is the equivalent of .MODEL.)
  764.  
  765.     public    _asm_func
  766. _asm_func    PROC    FAR USES SI DI DS, ASMARG:WORD
  767.  
  768. Change this to:
  769.     public    ASM_PROC
  770. ASM_PROC    PROC    FAR USES SI DI DS, ASMARG:WORD
  771.  
  772. 3. Similarly, if your assembly language functions use older style 
  773. segmentation, then your functions will take the form:
  774.  
  775.     public    _asm_func2
  776. _asm_func2    PROC
  777.     <executable statements>
  778. _asm_func2    ENDP  
  779.  
  780. Change this to:  
  781.  
  782.     public    ASM_FUNC2
  783. ASM_FUNC2    PROC
  784.     <executable statements>
  785. ASM_FUNC2    ENDP
  786.  
  787. 4. Far more preferable to the approach in item 3 above, modify your
  788. programs to use the TASM MODEL directive and the extended PROC syntax
  789. shown in item 2 above. The benefit of the extended PROC is that the all
  790. details of passing arguments and returning values are managed
  791. automatically by TASM, and you need not concern yourself with them.
  792.  
  793.  
  794.  
  795.         Converting Microsoft DOS Memory Management Functions
  796.  
  797. C programs written for the conventional MS-DOS environment rely on the
  798. Intel segmented architecture to access data on the heap. The Intel
  799. segmented architecture limits to 64K bytes the amount of data that can
  800. be accessed with one setting of a segment register. It also forces an
  801. arbitrary division between the near heap and the far heap.
  802.  
  803. The near heap is the heap space available in the default data segment
  804. after static and stack data have been allocated. The far heap consists
  805. of the remaining available conventional DOS memory after a program is
  806. loaded and its code, data, stack, and near heap space are allocated.
  807. Borland C++ and Microsoft C have slightly different but quite compatible
  808. heap manager implementations to deal with the intricacies of segmented
  809. architecture, but you need to convert Microsoft's non- standard heap
  810. function calls to ANS or Borland C++ function calls.
  811.  
  812. Borland C++ memory management design and implementation are more robust
  813. than Microsoft's. These are the advantages of Borland C++ memory
  814. management:
  815.  
  816. When a Borland C++ program starts up, the Borland C++ memory management
  817. functions treat all of the available conventional DOS memory as a single
  818. free far heap block. When a Microsoft C6.0a program starts up, its heap
  819. management run-time library normally allocates _amblksiz bytes of memory
  820. as the initial free far heap space. The Microsoft global variable
  821. _amblksiz has a default value of 8192 bytes.  Subsequently, the
  822. Microsoft C6.0a heap manager adds _amblksiz bytes of memory to the far
  823. heap whenever it has allocated all of the free far heap space and needs
  824. to get more from DOS. If your program uses the heap in an extremely
  825. dynamic manner, you will find Borland C++ memory management faster.
  826.  
  827. Borland C++ does not allocate memory blocks on the heap when a program
  828. requests a block size of zero bytes. This is treated as an error
  829. condition, because a heap allocation of zero bytes is logically
  830. inconsistent with good programming practice. Microsoft C allocates a
  831. heap block of zero bytes without indicating an error.
  832.  
  833. Borland C++ satisfies any single request for more than 64K bytes of heap
  834. space if your program is compiled with an appropriate memory model,
  835. compact, large, or huge. All of the far heap management functions
  836. support huge heap blocks, those that are greater than 64K bytes in size.
  837. Only the Microsoft C6.0a halloc and hfree functions allocate huge heap
  838. blocks.
  839.  
  840. When a program releases a memory block from the heap, the Borland C++
  841. heap manager cleans up free heap space. It also links together any free
  842. heap blocks that are consecutive in memory to form a single larger free
  843. heap block. This allows Borland C++ to reuse free heap space when your
  844. program makes a subsequent heap allocation request. With Microsoft C
  845. heap management, the free heap space remains fragmented, and it
  846. sometimes does not get reused. If your program, compiled under Microsoft
  847. C6.0a, allocates and deallocates memory very frequently, there is a
  848. reasonable probability that it will be unable to obtain a memory block
  849. to satisfy a memory allocation request.
  850.  
  851. Borland C++ allows your program to determine the status of free memory
  852. on a heap. However, it does not allow you to examine the contents of
  853. free heap memory, which is really not owned by your program. Microsoft C
  854. permits you to examine the contents of free heap directly. But neither
  855. memory management scheme can prevent your program from overwriting free
  856. heap memory if a pointer goes astray.
  857.  
  858. The Microsoft C functions that expand the heap do not move heap blocks
  859. in memory. The Borland C++ realloc functions sometimes relocate heap
  860. blocks in memory to increase the probability that a request to grow a
  861. heap block will be successful. As a rule, you should always make sure
  862. that any pointers aliased to heap blocks are updated after a realloc
  863. function.
  864.  
  865.  
  866. Microsoft C Based Heaps
  867. The nonstandard based heap feature was introduced initially by Microsoft
  868. with Version 6.0 of Microsoft C. Borland C++ does not support based
  869. pointers, and it has no function prototypes (function names _b...) for
  870. using the based heap. You would typically use based pointers in a large
  871. or huge memory model Microsoft C program to give you a faster method to
  872. accessing data than using the far heap. If your Microsoft C program uses
  873. based heap functions, you can take one of two possible courses of
  874. action: 
  875.  
  876. 1. Recompile your program with Microsoft C6.0a adding the following
  877. statement at the beginning of your program:
  878.         #define _MSC_VER 510
  879.  
  880. This directive forces the Microsoft C compiler to generate warning or
  881. fatal error messages for all references to based heap functions and the
  882. related elements _based, _segment, _self, and _segname. Replace the
  883. based heap functions with comparable far heap functions, change all
  884. references to _based pointers, remove all definitions of based variable
  885. types, and check out your program for correct operation.  Finally,
  886. recompile your program with Borland C++.
  887.  
  888. 2. Compile your program with Borland C++, and replace all based heap
  889. functions with borland far heap functions (farheap...), delete all
  890. _segment variables, and change the references to _based pointers.  Now,
  891. check out your program for correct operation.
  892.  
  893. Two sample programs, BASE_BEF.C and BASE_AFT.C, show you how to deal
  894. with the Microsoft C6.0a based variable functions and constructs. 
  895. BASE_BEF.C exercises the Microsoft based variable and based heap memory
  896. management functions. BASE_AFT.C achieves the same end result by using
  897. the Borland C++ farheap instead of the Microsoft based heap. These
  898. programs are available for download (see the appendix for more details).
  899.  
  900.  
  901. General Comparison of Heap Functions
  902. The following sections contain a comparison of Microsoft C and Borland
  903. C++ heap functions. Two sample programs MFARHEAP.C and BFARHEAP.C show
  904. you how to convert from Microsoft C6.0a far heap calls to Borland C++
  905. far heap calls.  MFARHEAP.C exercises the Microsoft far heap memory
  906. management functions prefixed by the _f symbols. BFARHEAP.C achieves the
  907. same end result by using the Borland C++ farheap functions. These
  908. programs are available for download (see the appendix for more details).
  909.  
  910.  
  911.  
  912. heapadd functions.
  913. The Microsoft heapadd functions, _heapadd and _bheapadd, expand the size
  914. of the appropriate heap by requesting additional memory from DOS and
  915. adding it to the threaded list used to manage heap space. Note that all
  916. of these functions are non-portable and non-standard. When a Microsoft
  917. C6.0a program starts up, the heap management run-time library normally
  918. allocates _amblksiz bytes of memory, but less than the total amount of
  919. unused DOS conventional memory. The default value for _amblksiz is 8192.
  920. Subsequently, the Microsoft C6.0a heap manager adds _amblksiz bytes of
  921. memory to the far heap whenever it has run out of free heap space.
  922.  
  923. Borland C++ has no corresponding heapadd functions because it manages
  924. free heap space differently. When a program compiled with Borland C++
  925. starts up, the heap management run-time library allocates all of the
  926. unused DOS conventional memory as free far heap.
  927.  
  928. Recommended Action: Remove heapadd function calls, or insert the
  929. following #define which causes the C preprocessor to ignore all
  930. occurrences of the function call:
  931.  
  932.  #define _heapadd(a,b)
  933.  
  934. expand functions.
  935. The Microsoft C6.0a expand functions, _expand, _bexpand, _fexpand, and
  936. _nexpand, change the size of a previously allocated block of heap
  937. memory. The size of a memory block may become either larger or smaller
  938. as the result of a Microsoft C6.0a expand function. An expand function
  939. does not move a block around in memory to make it larger. If an expand
  940. function cannot increase the size of a heap block because the memory
  941. above it is already allocated, it returns an error.
  942.  
  943. Borland C++ has no corresponding expand functions because it manages
  944. free heap space dynamically, but the Borland C++ realloc functions,
  945. realloc and farrealloc, perform a task similar to the expand functions.
  946. These functions do relocate a heap block if required, so they are less
  947. likely to fail to expand a heap block than the Microsoft C expand
  948. functions.
  949.  
  950. Recommended Actions: Substitute realloc function calls for Microsoft
  951. expand function calls, using realloc in place of either _expand or
  952. _nexpand, and farrealloc in place of either _fexpand or _bexpand.  Since
  953. realloc returns a pointer to the memory block, which may have been
  954. relocated, you will also have to make sure that you always use the new
  955. pointer value when referring to data in the reallocated heap block. If
  956. possible, use the ANSI standard realloc function in preference to the
  957. DOS-specific farrealloc.
  958.  
  959.  
  960.  
  961. heapchk functions.
  962. The Microsoft C6.0a heapchk functions, _heapchk, _bheapchk, _fheapchk,
  963. _nheapchk, check the consistency of an entire heap. With Microsoft C6.0a
  964. memory management, there are three possible error conditions: the heap
  965. header control area is invalid, the heap area is uninitialized, or a
  966. heap node contains invalid data.
  967.  
  968. Borland C++ provides the heapcheck and farheapcheck functions that
  969. accomplish the same objective as the Microsoft heapchk functions.  They
  970. return only two error conditions: the heap area is uninitialized, and
  971. the heap is corrupted.
  972.  
  973. Recommended Action: Substitute heapcheck function calls for Microsoft
  974. _heapchk function calls, using heapcheck in place of either _heapchk or
  975. _nheapchk, and farheapcheck in place of either _fheapchk or _bheapchk.
  976. The sample programs MFARHEAP.C and BFARHEAP.C in the following section
  977. entitled "Converting from Microsoft Heap Management to Borland C++ Heap
  978. Management" show how this is done with a #define for _fheapchk.
  979.  
  980.  
  981.  
  982. heapmin functions.
  983. The Microsoft C6.0a heapmin functions, _heapmin, _bheapmin, _fheapmin,
  984. and _nheapmin, release unused heap memory to DOS.
  985.  
  986. Borland C++ has no corresponding heapmin functions because it manages
  987. free heap space differently. See the discussion under heapadd Functions.
  988.  
  989. Recommended Action: Remove heapmin function calls or insert the
  990. following #define which causes the C preprocessor to ignore all
  991. occurrences of the function call:
  992.  
  993.  
  994.  
  995. #define _heapmin()
  996.  
  997.  
  998.  
  999. heapset functions.
  1000. The Microsoft C6.0a heapset functions, _heapset, _bheapset, _fheapset,
  1001. and _nheapset, check a heap for consistency and initialize all bytes of
  1002. free heap memory to a constant value. Your program can later verify that
  1003. the heap has not be overwritten by a stray pointer by checking all free
  1004. heap memory for the same constant value using a matching heapchk
  1005. function.
  1006.  
  1007. Borland C++ provides the heapfillfree and farheapfillfree functions that
  1008. accomplish the same objective as the Microsoft heapset functions.  Both
  1009. the Microsoft heapset and Borland C++ heapfillfree functions return the
  1010. same error conditions as their corresponding heapchk functions.
  1011.  
  1012. Recommended Action: Substitute Borland C++ heapset function calls for
  1013. Microsoft _heapset function calls, using heapset in place of either
  1014. _heapset or _nheapset, and farheapset in place of either _fheapset or
  1015. _bheapset. The sample programs MFARHEAP.C and BFARHEAP.C show how this
  1016. is done with a #define for _fheapset.
  1017.  
  1018.  
  1019.  
  1020. heapwalk functions.
  1021. The Microsoft C6.0a heapwalk functions, _heapwalk, _bheapwalk,
  1022. _fheapwalk, and _nheapwalk, traverse the heap and return a heap
  1023. structure containing information about the next heap entry. Prior to
  1024. calling a heapwalk function, you initialize the heap structure with a
  1025. pointer value, either to a valid heap block, or NULL, if you want to get
  1026. information about the first block in the threaded heap list. The
  1027. Microsoft heapwalk functions return heap information about all heap
  1028. blocks of a given type, whether allocated or free. They return the size
  1029. of the heap block that was allocated, excluding control structures and
  1030. padding bytes.
  1031.  
  1032. Borland C++ provides the heapwalk and farheapwalk functions that
  1033. accomplish an objective similar to the Microsoft heapwalk functions. 
  1034. However, the Borland C++ heapwalk functions return heap information only
  1035. about heap blocks that are currently allocated to your program. It also
  1036. returns the size of the heap block including control structures and
  1037. padding bytes.
  1038.  
  1039. Recommended Actions: Substitute heapwalk function calls for Microsoft
  1040. _heapwalk function calls, using heapwalk in place of either _heapwalk or
  1041. _nheapwalk, and farheapwalk in place of either _fheapwalk or _bheapwalk.
  1042. You may also have to change the logic of your program slightly to use
  1043. these functions which are primarily an adjunct to debugging. The sample
  1044. programs MFARHEAP.C and BFARHEAP.C show how this is done with a #define
  1045. for _fheapwalk.
  1046.  
  1047.  
  1048. msize functions.
  1049. The Microsoft C6.0a msize functions, _msize, _bmsize, _fmsize, and
  1050. _nmsize, return the size of a memory block allocated on the heap with a
  1051. given pointer. Borland C++ has no similar function.
  1052.  
  1053. Recommended Actions: Every time you allocate a memory block using one of
  1054. the malloc functions or change its size with a realloc function, you
  1055. will need to save and tabulate the number of bytes allocated, kept on a
  1056. one-to-one basis with the pointer to the allocated memory. Then, change
  1057. every reference to an msize function and its associated pointer argument
  1058. to use the number of bytes previously allocated for that pointer. DO NOT
  1059. use the Borland C++ heapwalk functions to find out the size of a memory
  1060. block on the heap, because these functions return a value that includes
  1061. the size of heap block control structure and any padding bytes. The
  1062. sample programs MFARHEAP.C and BFARHEAP.C show how this might be done.
  1063.  
  1064.  
  1065.  
  1066.  
  1067. Other Microsoft Based Heap Functions
  1068. Microsoft C6.0a has other functions that allocate, reallocate and
  1069. release memory from a based heap. These functions are _bcalloc, _bfree,
  1070. _bmalloc, and _brealloc. The _bheapseg and _bfreeseg functions allocate
  1071. and deallocate based heap segments, respectively. Borland C++ does not
  1072. support the based heap, based pointers, and _segment variables.
  1073.  
  1074. Recommended Actions: Remove all _bheapseg and _bfreeseg function calls,
  1075. and all definitions of variables of the type _segment. Change all _based
  1076. pointers to _far pointers. As a general rule when converting to Borland
  1077. C++, substitute either the corresponding ANSI standard memory allocation
  1078. function, or the corresponding Borland C++ far heap memory allocation
  1079. function. You should use ANSI standard functions whenever possible to
  1080. facilitate portability, as long as they permit you to manage memory as
  1081. you need to do. Because all of the Microsoft C6.0a based heap functions
  1082. take an additional segment variable as an argument, it is not
  1083. straightforward to write a set of #define's to make the substitution.
  1084. The sample programs BASE_BEF.C and BASE_AFT.C serve together as an
  1085. example to show you how to convert programs that used based heap
  1086. variables.
  1087.  
  1088.  
  1089.  
  1090. freect
  1091. The Microsoft _freect function inquires about the maximum number of
  1092. items can be allocated on the near heap, where an item is a fixed number
  1093. of bytes in size. _freect would typically be used in tiny, small or
  1094. medium memory model Microsoft C programs.
  1095.  
  1096. Borland C++ does not have a similar function, but it does have the
  1097. coreleft function that returns the total number of bytes of unused
  1098. memory at the top of the heap.
  1099.  
  1100. Recommended Actions: Substitute the coreleft function for _freect. 
  1101. Compute the effective item size by adding six to the item size then
  1102. round it up to the nearest multiple of 16. Finally, compute the maximum
  1103. number of items that can be allocated by dividing the memory left by the
  1104. effective item size, and pass this argument to coreleft.  The Borland
  1105. C++ heap management functions require a six byte control structure for
  1106. each heap block. They always allocate a heap block on a paragraph
  1107. boundary, demanding that the effective size allocated is an exact
  1108. multiple of 16.
  1109.  
  1110.  
  1111.  
  1112.  
  1113. Keeping Out of Heaps of Trouble
  1114. Here are some other tips to help you work effectively with the Borland
  1115. C++ heap manager.
  1116.  
  1117. The Microsoft C _nheap family of functions map directly into the ANSI
  1118. heap functions of Borland C++.
  1119.  
  1120. The Microsoft C _fheap family of functions map directly to the Borland
  1121. C++ farheap set of functions, as shown by the sample MFARHEAP.C and
  1122. BFARHEAP.C programs.
  1123.  
  1124. To have the greatest degree of portability and to guarantee defect- free
  1125. program, whenever you reallocate heap space, always make sure that you
  1126. use the current segment:offset value of a heap pointer returned by the
  1127. heap manager. And, especially, be sure that any pointers derived from
  1128. the pointer returned by the heap manager are all initialized to the
  1129. latest value before use.
  1130.  
  1131.  
  1132.                       Environments and tools
  1133.  
  1134.  
  1135. The Borland C++ IDE is roughly the equivalent of the Programmer's
  1136. Workbench, although naturally we think you'll find the IDE much easier
  1137. to use. Chapter 3 of the Borland C++ User's Guide manual provides a
  1138. complete reference to the IDE.
  1139.  
  1140. The IDE loads its settings from two files: TCCONFIG.TC, the default
  1141. configuration file, and a project file (.PRJ). TCCONFIG.TC contains
  1142. general environmental information. The current project file contains
  1143. information more specific to the application you're building.
  1144.  
  1145. A project is the IDE's equivalent of a makefile. It includes the list of
  1146. files to be built, as well as settings for the IDE options that control
  1147. the compilation and linkage of that program. If you don't specify a
  1148. project file when you start the IDE, a nameless project is opened and
  1149. set with default compiler and linker options, but no file name list.
  1150.  
  1151. Unlike Microsoft C, however, Borland C++ does not automatically create
  1152. and run a makefile based on settings and file names that you give it in
  1153. the project. If you want to use the IDE to set up a project, but use
  1154. MAKE to do the actual build, then you can use the PRJ2MAK utility to
  1155. convert a project file to a makefile.
  1156.  
  1157. The following sections describe the significant differences between
  1158. Borland C++'s MAKE, Project Manager, linker (TLINK), and command-line
  1159. compiler (BCC) and Microsoft C's NMAKE, LINK, and CL.
  1160.  
  1161.  
  1162.  
  1163. Paths for .h and .LIB files
  1164. Microsoft C requires two environment variables, LIB and INCLUDE. The
  1165. Microsoft C compiler uses INCLUDE to find standard header files.
  1166. Similarly, the Microsoft linker uses the LIB variable to discover the
  1167. location of the run-time libraries. Borland C++ does not use environment
  1168. variables to store the paths for the library and the include files.
  1169. Instead, you can easily set these paths in the IDE using the environment
  1170. options. If you are working with the command-line compiler or the
  1171. linker, you can use either command-line options or configuration files.
  1172.  
  1173.  
  1174.  
  1175. Remember that even if you haven't opened a project, Borland C++ will
  1176. store the paths in its default project file.
  1177.  
  1178.  
  1179. When you install Borland C++, you are asked to set paths for include
  1180. files and library files. Those paths become the default paths in the
  1181. IDE. The include and library files paths are also written to the default
  1182. command-line compiler configuration file TURBOC.CFG. The library path is
  1183. written to the default standalone linker configuration file TLINK.CFG. 
  1184.  
  1185.  
  1186. In the IDE, you can change the default search paths for libraries and
  1187. header files with the Options|Directories command. The settings in the
  1188. Directories dialog box become a part of the current project.
  1189.  
  1190. For the command-line compiler, you can change the search path for
  1191. include and library files with the -I and -L options, respectively.
  1192. These options can also be changed in the configuration file for the
  1193. command-line compiler, TURBOC.CFG.
  1194.  
  1195. The linker can use the /L option to set search paths for libraries and
  1196. initialization code (like C0S.OBJ, the startup code for the small memory
  1197. model). For instance, this option
  1198.  
  1199.  
  1200. /LC:\BORLANDC\LIB;C:\WINAPPS\LIB
  1201.  
  1202.  
  1203. tells the linker to look in the two paths named for library and
  1204. initialization files.
  1205.  
  1206. You can also create a TLINK.CFG file. TLINK.CFG is a regular text file
  1207. that contains a list of valid TLINK options.
  1208.  
  1209. For the Windows Resource Compiler, the -x option tells it to ignore the
  1210. INCLUDE variable. In addition, you can specify an additional search path
  1211. with the -i option ( -i all by itself does not imply -x).")
  1212.  
  1213. When the Resource Compiler is invoked from the command line, it looks
  1214. for windows.h on the path specified by the INCLUDE environment variable,
  1215. if there is one. If that INCLUDE variable is set to some path other than
  1216. the location of the windows.h supplied by Borland C++, your module might
  1217. not be compiled correctly. (This does not occur in the IDE, because the
  1218. IDE passes the correct information to the Resource Compiler.)
  1219.  
  1220. For instance, if you have been using Microsoft C, then you probably have
  1221. an INCLUDE environment variable set to the path of the Microsoft C
  1222. header files. If you have also been using the Microsoft Windows SDK,
  1223. then the version of windows.h included with the SDK is probably also in
  1224. the INCLUDE directory.
  1225.  
  1226. When you're building a Borland C++ application, the Resource Compiler
  1227. should include the windows.h shipped with Borland C++. If you have a
  1228. defined INCLUDE environment variable, then you should tell the Resource
  1229. Compiler to ignore it with the -x option. (The same holds true for
  1230. Microsoft C LIB environment variable, i.e. it contains both the standard
  1231. C library path and the Windows library path, the latter only if you are
  1232. writing for Windows and you have installed the Windows library in a path
  1233. different than the standard MSC C libraries.)
  1234.  
  1235.  
  1236. MAKE
  1237. The version of MAKE supplied with Borland C++ 3.0 contains many new
  1238. features, some of which are designed to increase compatibility with
  1239. Microsoft's NMAKE. The new command-line switch -N turns on full NMAKE
  1240. compatibility. See Chapter 2 of the Borland C++ Tools & Utilities Guide
  1241. manual for more information on MAKE's options. The following list
  1242. summarizes the differences between MAKE and NMAKE.
  1243.  
  1244. NMAKE supports response files but MAKE doesn't.
  1245.  
  1246. In NMAKE, you must surround strings to be compared with quotes. MAKE
  1247. doesn't have this requirement; as long as the string to be compared
  1248. doesn't contain spaces, you can compare them without quotes.
  1249.  
  1250. NMAKE predefines several implicit rules; MAKE doesn't. However, the
  1251. BUILTINS.MAK file contains several implicit rules that you can use
  1252. without specifying them in the makefile.
  1253.  
  1254. MAKE doesn't pass through environment variables.
  1255.  
  1256.  
  1257. Command-line Compiler
  1258.  
  1259. The following table lists comparable BCC and CL command-line compiler
  1260. options. Some of the CPP (standalone preprocessor) options are listed.
  1261. In many multi-pass compilers, a separate pass performs the work of the
  1262. preprocessor, and the results of the pass can be examined. Since Borland
  1263. C++ uses an integrated single-pass compiler, we provide the standalone
  1264. utility CPP to supply the first-pass functionality found in other
  1265. compilers.
  1266.  
  1267. Note that most CL options that take arguments allow for a space between
  1268. the option and the argument. BCC options that take arguments are usually
  1269. immediately followed by the argument or list.
  1270.  
  1271. CL and BCC options compared
  1272. Microsoft C    Borland C++
  1273. CL option  BCC option    What it does
  1274.     N/A     @name         Gives the command-line
  1275.                           compiler a response
  1276.                           file name.
  1277.     N/A     +name         Tell the command-line
  1278.                           compiler to use the
  1279.                           alternate configuration
  1280.                           file name
  1281.     N/A     -A            ANSI keywords
  1282.     N/A     -A-, -AT      Borland C++ keywords
  1283.                           (default)
  1284.     N/A     -AK           Use only Kernighan and
  1285.                           Ritchie keywords.
  1286.     N/A     -AU           Use only UNIX keywords.
  1287.     /Zp2    -a            Align word.
  1288.     /Zp1    -a-           Align byte (default).
  1289.   /Aw, /Gw  -WD           Creates an .OBJ for Windows
  1290.                           to be linked as a .DLL with
  1291.                           all functions exportable.
  1292.   /Aw, /GW  -WDE          Creates an .OBJ for Windows
  1293.                           to be linked as a .DLL with
  1294.                           explicit export functions.
  1295.     /Ax     -mx           Use memory model x, where x
  1296.                           is t, s, m, c, l, or h.. For
  1297.                           BCC, following t, s, or m
  1298.                           with ! tells compiler to
  1299.                           assume DS != SS.
  1300.     /Bn      N/A          Use alt preprocessor CnL.
  1301.     N/A     -B            Compile and call the
  1302.                           assembler to process inline
  1303.                           assembly code.
  1304.     N/A     -b            Make enums word-sized
  1305.                           (default)
  1306.     N/A     -b-           Make enums signed
  1307.                           or unsigned.
  1308.     /C      N/A           Preserve comments in C
  1309.                           preprocessor
  1310.     N/A     -C            Nested comments on.
  1311.     N/A     -C-           Nested comments off.(default)
  1312.     /c      -c            Compile to .OBJ but do
  1313.                           not link.
  1314.     /Did  -Dname          Define 'name' to the string
  1315.                           consisting of the null character.
  1316.  /Did=value -Dname=string Defines 'name' to 'string'.
  1317.     N/A     -d            Merge duplicate strings on.
  1318.     N/A     -d-           Merge duplicate strings off
  1319.                           (default) (default).
  1320.     N/A     -Ename        Use filename as the
  1321.                           assembler to use.
  1322.     /E     CPP -P         Preprocess source to
  1323.                           standard output, include
  1324.                           line numbers.
  1325.     /EP    CPP -P-        Preprocess source to
  1326.                           standard output, without
  1327.                           line numbers.
  1328.     N/A     -f-           Don't do floating point.
  1329.     N/A     -ff           Fast floating point (default).
  1330.     N/A     -ff-          Strict ANSI floating point
  1331.     N/A     -ff-          Strict ANSI floating point.
  1332.     N/A     -f87          Use 8087 h/w instructions.
  1333.     N/A     -f287         Use 80287 h/w instructions.
  1334.   /F hexnum  N/A          Sets stack size to hexnum
  1335.                           bytes (hexnum must be
  1336.                           hexadecimal).
  1337. (By default) -Fc          Generates COMDEFs.
  1338.     N\A      -Fm          Enables the -Fc, -Ff, and
  1339.                           -Fs     options.
  1340. (By default) -Fs          Make DS==SS for all
  1341.                           memory models
  1342. /Fa [file]   N/A          Create assembly listing.
  1343.                           Name for list file defaults
  1344.                           to Source.ASM.
  1345.     /Fb      N/A          Creates a bound executable file
  1346. /Fc [file]   -S           Produces a combined source
  1347.                           and assembly code listing.
  1348.                           Name for list file defaults
  1349.                           to Source.COD.
  1350. /Fe file   -efile         'file' names executable file.
  1351. /Fl [file]   N/A          Creates object code list.
  1352.                           Name for list file defaults
  1353.                           to Source.COD.
  1354. /Fm [file]   -M           Creates map file. Name
  1355.                           defaults to Source.MAP,
  1356.                           where source is the first
  1357.                           source file specified.
  1358. /Fo file   -ofile         'file' names object file.
  1359.     /FPa    N/A           Generate floating-point
  1360.                           calls; select alternate math
  1361.                           library.
  1362.     /FPc    -f            Emulate floating point
  1363.                           (default, coprocessor used if
  1364.                            present at run time).
  1365.     /FPc87  N/A           Selects 80x87 library (80x87
  1366.                           coprocessor must be present
  1367.                           at run time).
  1368.     /FPi    N/A           Inlines 80x87 instructions;
  1369.                           selects emulator library
  1370.                           (coprocessor used if present
  1371.                           at run time).
  1372.     /FPi87  -f87, -f287   Inlines 80x87 instructions;
  1373.                           chooses coprocessor library
  1374.                           (coprocessor must be present
  1375.                           at run time).
  1376.  
  1377.   /F[file]   N/A          Generates standard PWB
  1378.                           Source Browser database.
  1379.   /FR[file]  N/A          Generates extended PWB
  1380.                           Source Browser database.
  1381.   /Fs [file] N/A          Produce source list file.
  1382.                           defaults to Source.LST.
  1383.   /Fx [file] N/A          'file' specifies a name
  1384.                           for the MASM cross-reference
  1385.                           file.
  1386.     G0      -1-           Generate 8088/8086
  1387.                           instructions.
  1388.     G1      -1            Generate 80186 instructions.
  1389.     G2      -2            Generate 80286
  1390.                           protected-mode compatible
  1391.                           instructions.
  1392.     /Gc     -p            Use Pascal calling
  1393.                           convention. For CL, this is
  1394.                           Pascal or FORTRAN, but they
  1395.                           currently same calling
  1396.                           convention.
  1397.     /Gd     -p-           Standard C calling
  1398.                           conventions (default).
  1399.     /Ge     -N            Check for stack overflow.
  1400.                           (Default for CL, but not for
  1401.                           BCC).
  1402.     /Gi     N/A           Compile incrementally (for
  1403.                           use with quick compile
  1404.                           option /qc).
  1405.     /Gm     N/A           Store strings in CONST seg
  1406.     N/A    -gn            Stop compilation after n
  1407.                           warning messages
  1408.     /Gr    -pr            Enables _fastcall to call
  1409.                           conventions for functions
  1410.                           (if possible, passing value
  1411.                           in registers).
  1412.     /Gs     -N-           Turn off checking for stack
  1413.                           overflow. (Off by default
  1414.                           for BCC.)
  1415.  /Gt [number] -Ff[=size]  Creates far variables
  1416.                           automatically; 'size' or
  1417.                           'number' is threshold.
  1418.     /Gw      -W           Creates correct
  1419.                           prolog/epilog for Windows
  1420.                           program. For Borland C++,
  1421.                           this creates an application
  1422.                           with all functions exportable
  1423.     /GW     -WE           Generates prolog/epilog for
  1424.                           explicit functions (marked
  1425.                           with _export) in Windows
  1426.                           program.
  1427.     N/A      -H           Causes the compiler to
  1428.                           generate and use pre-
  1429.                           compiled headers.
  1430.     N/A      -H-          Turns off generation and
  1431.                           use of precompiled headers
  1432.                           (default).
  1433.     N/A      -Hu          Tells the compiler to use
  1434.                           but not generate precompiled
  1435.                           headers.
  1436.     N/A   -H=filename     Sets the name of the file
  1437.                           for precompiled headers.
  1438. (By default) -h           Use fast huge ptr math
  1439.  /H number  -inumber      Restricts length of external
  1440.                           names to 'number'.
  1441.     /HELP   BCC           Calls QuickHelp. For help on
  1442.                           BCC, simply invoke without
  1443.                           options.
  1444.     N/A     -in           Make significant identifier
  1445.                           length to be 'n'.
  1446.   /I dir  -Ipath          Directories for include files
  1447.                           For CL, adds directory to the
  1448.                           beginning of include file
  1449.                           search directory list.
  1450.     N/A   -jn             Stop after 'n' compiler error
  1451.                           messages.
  1452.     /J    -K              Changes default for char.
  1453.                           from signed to unsigned. For
  1454.                           Borland C++, -K- returns to
  1455.                           signed.
  1456.     N/A   -Jg             Definitions for all template
  1457.                           instances, and merge
  1458.                           duplicates (default)
  1459.     N/A  -Jgd             Public definitions for all
  1460.                           template instances
  1461.     N/A  -Jgx             External references for all
  1462.                           template instances
  1463.     N/A  -k               Std stack frame on (default).
  1464.     N/A -Lpath            Directories for libraries.
  1465.  /Lc,/Lr  /Td             Tells linker to create a
  1466.                           real mode executable.
  1467. /Li [number]  N/A         Use incremental linker,
  1468.                           instead of standard linker.
  1469.                           Number specifies byte
  1470.                           boundary for padding near
  1471.                           functions.
  1472.  /Lr See /Lc.
  1473.  /link opts -lopts        Pass 'opts' to linker when
  1474.                           invoked.
  1475.    N/A      -l-option     Suppress 'option' for the linker
  1476.    N/A      -M            Instruct the linker to
  1477.                           create a map file.
  1478.  /MA option -Toption      Pass 'option' to assembler
  1479.                           when invoked.
  1480.    N/A      -npath        Set the output directory
  1481.  /NDdataseg -zRname       Sets the data segment name.
  1482.                           For BCC, option changes the
  1483.                           name of the uninitialized
  1484.                           data segment class to name.
  1485.                           By default, the uninitialized
  1486.                           data segments are assigned
  1487.                           to class BSS.
  1488.  /NMmodule   N/A          Sets module name to 'module'
  1489.  /nologo     N/A          Don't print sign-on banner.
  1490.  /NTsegname -zCname       Sets code segment name. This
  1491.                           option changes the name of
  1492.                           the code segment to 'name'. By
  1493.                           default, the code segment is
  1494.                           named _TEXT, except for the
  1495.                           medium, large and huge
  1496.                           models, where the name is
  1497.                           filename_TEXT. (filename
  1498.                           here is the source file name.)
  1499.     N/A     -O            Optimize jumps.
  1500.     N/A     -O-           No optimization (default).
  1501.    /O [options] (See comment)   Provides optimization. For
  1502.                           Borland C++, see specific
  1503.                           options; for instance, -Z,
  1504.                           -O, or -G.
  1505.     /Os     -G-           Optimize for size (default)
  1506.     /Os     -O1           Optimize, smallest code
  1507.     /Ot     -G            Optimize for speed
  1508.     /Ot     -O2           Optimize, fastest code
  1509.     /Oa     -Oa           Optimize, no pointer aliasing
  1510.     /Ow      N/A          no aliasing in function calls
  1511.     N/A     -Ob           Optimize, dead store
  1512.                           elimination
  1513.     /Og     -Oc           Optimize, local common
  1514.                           subexpression elimination
  1515.     /Od     -Od           Optimize, disable all
  1516.                           optimizations
  1517.     /Oe     -Oe           Optimize, global register
  1518.                           allocation, variable live range
  1519.     /Og     -Og           Optimize, global common
  1520.                           subexpression elimination
  1521.     /Oi     -Oi           Optimize, intrinsic functions,
  1522.                           automatic inlining
  1523.     /Ol     -Ol           Optimize, loop optimization
  1524.     /Ol     -Om           Optimize, loop invariants,
  1525.                           code motion on
  1526.     /On     N/A           disable "unsafe" optimizations
  1527.     N/A     -Op           Optimize, copy propagation
  1528.     /Op     N/A           enable precision optimizations
  1529.     /Or     N/A           disable inline return
  1530.     /Os     -Os           Optimize, size of code
  1531.     /Ot     -Ot           Optimize, speed of .EXE
  1532.     /Ol     -Ov           Optimize, loop induction
  1533.                           variable, strength reduction
  1534.     /Ox     -Ox           Optimize, speed: compatible
  1535.                           with Microsoft compilers
  1536.     N/A     -P            Perform a C++ compile
  1537.                           regardless of source file
  1538.                           extension.
  1539.     N/A     -Pext         Perform a C++ compile and
  1540.                           set the default extension to
  1541.                           ext.
  1542.     N/A     -P-           Perform a C++ or C compile
  1543.                           depending on source file
  1544.                           extension (default).
  1545.     N/A     -P-ext        Perform a C++ or C compile
  1546.                           depending on extension; set
  1547.                           default extension to ext.
  1548.     N/A     -p-           Use C calling convention
  1549.                           (default).
  1550.     /P  CPP -P- -oname    Preprocesses source file and
  1551.                           sends output to name
  1552.                           (CPP), or to Source.I (CL).
  1553.     N/A     -Qe           Instructs the compiler to
  1554.                           use all available EMS memory
  1555.                           (default).
  1556.     N/A     -Qe-          Instructs the compiler to
  1557.                           not use any EMS memory.
  1558.     N/A     -Qx           Instructs the compiler to
  1559.                           use all available extended
  1560.                           memory.
  1561.     N/A     -Qx=nnnn      Instructs the compiler to
  1562.                           reserve nnnn Kb of extended
  1563.                           memory for other programs,
  1564.                           and to use the rest itself.
  1565.     N/A     -Qx=nnnn,yyyy Instructs the compiler to
  1566.                           reserve 'nnnn' Kb of extended
  1567.                           memory for other programs
  1568.                           and 'yyyy' for itself.
  1569.     N/A     -Qx=,yyyy     Instructs the compiler to
  1570.                           reserve 'yyyy' Kb of extended
  1571.                           memory for itself.
  1572.     N/A     -Qx-          Instructs the compiler to
  1573.                           not use any extended memory
  1574.     /qc     N/A           Invokes quick compile.
  1575.     N/A     -R            Generate ObjectBrowser
  1576.                           information.
  1577.     N/A     -r            Use register variables on
  1578.                           (default).
  1579.     N/A     -r-           Suppresses the use of
  1580.                           register variables.
  1581.     N/A     -rd           Only allow declared
  1582.                           register variables to
  1583.                           be kept in registers.
  1584.     N/A     -S            Produce .ASM file
  1585.    /Sx option  N/A        Set options for source
  1586.                           listing. Where 'x' is l, p,
  1587.                           s, or t.
  1588.     N/A     -T-           Remove all previous
  1589.                           assembler options.
  1590.    /Ta asm_src  N/A       Specifies that 'asm_src' be
  1591.                           treated as an assembler
  1592.                           source file.
  1593.    /Tc srcfile  N/A       Specifies that 'srcfile' be
  1594.                           treated as a c source file.
  1595.     N/A    -tDe           Compiled and linked program
  1596.                           is DOS .EXE file
  1597.     N/A    -tDc           Compiled and linked program
  1598.                           is DOS .COM file
  1599.     N/A    -tW            Compiled and linked program
  1600.                           is a Windows module using
  1601.                           the -W options
  1602.     N/A    -u             Generate underscores (default)
  1603.     N/A    -u-            Disable underscores
  1604.     /u     N/A            Undefines all predefined
  1605.                           identifiers
  1606.  /U Ident  -UIdent        Undefine any previous
  1607.                           definitions of 'Ident'.
  1608.     N/A    -V             Smart C++ virtual tables.
  1609.     N/A    -Va            Pass class args by reference
  1610.                           to temp variable
  1611.     N/A    -Vb            Backwards compatibility,
  1612.                           virtual base class pointer
  1613.     N/A    -Vc            Backwards compatibility,
  1614.                           no hidden members and code
  1615.     N/A    -Vf            C++ far virtual tables
  1616.     N/A    -Vmv           Member pointers have no
  1617.                           restrictions
  1618.     N/A    -Vmm           Member pointers support
  1619.                           multiple inheritance
  1620.     N/A    -Vms           Member pointers support
  1621.                           single inheritance
  1622.     N/A    -Vmd           Use smallest representation
  1623.                           for member pointers
  1624.     N/A    -Vmp           Honor declared precision for
  1625.                           all member pointer types
  1626.     N/A    -Vo            Backwards compatibility,
  1627.                           master switch turns on all
  1628.     N/A    -Vp            Backwards compatibility,
  1629.                           pass 'this' to pascal
  1630.                           member functions
  1631.     N/A    -Vt            Place virtual table pointer
  1632.                           after non-static data members
  1633.     N/A    -Vs            Local C++ virtual tables.
  1634.     N/A    -Vv            Backwards compatibility,
  1635.                           don't change layout of classes
  1636.     N/A    -VmX           C++ member pointers
  1637.     N/A  -V0, -V1         External and Public C++
  1638.                           virtual tables.
  1639.     N/A    -Vf            Far C++ virtual tables.
  1640.     N/A    -v             Source debugging on
  1641.     N/A    -v-            Source debugging off
  1642.     N/A   -vi, -vi-       Controls expansion of inline
  1643.                           functions.
  1644.  /V string N/A            Copies 'string' to object file
  1645.                           (for version control).
  1646.     N/A    -w             Display warnings on.
  1647.     N/A    -wxxx          Enable 'xxx' warning message.
  1648.     N/A    -w-xxx         Disable 'xxx' warning message.
  1649.     /w     -w-            Display warnings off.
  1650.     N/A    -WS            Creates an .OBJ for Windows
  1651.                           that uses smart callbacks.
  1652.     /W n   (See -w)       Set warning level 0, 1, 2,
  1653.                           3, or 4.
  1654.     /WX   -g1             Makes all warnings fatal. No
  1655.                           object files are generated
  1656.                           if warning occurs. (The -g
  1657.                           option takes the form -gn,
  1658.                           where n is the limit to
  1659.                           number of warnings.)
  1660.     N/A    -X             Disable compiler
  1661.                           autodependency output.
  1662.     /X     N/A            Ignore INCLUDE
  1663.                           environment variable list
  1664.                           of include search paths.
  1665.     N/A    -Y             Enable overlay code
  1666.                           generation.
  1667.     N/A    -Yo            Overlay the compiled files.
  1668.     N/A    -y             Include line numbers in
  1669.                           .OBJ for debugger
  1670.     N/A    -y-            Do not include line numbers
  1671.                           in .OBJ for debugger
  1672.     N/A    -Z             Enable register usage
  1673.                           optimization.
  1674.     N/A   -zAname         set Code class to 'name'
  1675.     N/A   -zBname         set BSS class to 'name'
  1676.     N/A   -zDname         set BSS segment to 'name'
  1677.     N/A   -zEname         set Far segment to 'name'
  1678.     N/A   -zFname         set Far class to 'name'
  1679.     N/A   -zGname         set BSS group to 'name'
  1680.     N/A   -zHname         set Far group to 'name'
  1681.     N/A   -zPname         set Code group to 'name'
  1682.     N/A   -zSname         set Data group to 'name'
  1683.     N/A   -zTname         set Data class to 'name'
  1684.     N/A   -zX*            Use default segment, class,
  1685.                           or group name for X.
  1686.     /Za    -A             Enforces ANSI compatibility.
  1687.                           Use only ANSI keywords. No
  1688.                           vendor-specific extension
  1689.                           allowed.
  1690.     /Zc    N/A            Ignores case for functions
  1691.                           declared as _pascal.
  1692.     /Zd    /y             Generates line numbers for
  1693.                           symbolic debugger.
  1694.     /Ze -A-, -AT          Enable vendor-specific
  1695.                           extensions.
  1696.     /Zg    N/A            Generates function
  1697.                           prototypes; writes to
  1698.                           standard output.
  1699.     /Zi    /v             For Microsoft, generates
  1700.                           debugger information for
  1701.                           CodeView. For Borland C++,
  1702.                           generates information for
  1703.                           IDE debugger and Turbo
  1704.                           Debugger.
  1705.     /Zl   N/A             Library search records not
  1706.                           written to object file.
  1707.     /Zpn -a, -a-          Packs structure members
  1708.                           on the 'n' byte boundary.
  1709.                           'n' can be 1, 2, or 4.
  1710.     /Zr   N/A             Generates checks for null
  1711.                           pointers and far pointers
  1712.                           that are out of range.
  1713.  /Zs files  N/A           Syntax check only.
  1714.  
  1715.  
  1716. Command-line Options and Libraries
  1717.  
  1718. The C0Fx.OBJ modules are provided for compatibility with source
  1719. files intended for compilers from other vendors. The C0Fx.OBJ
  1720. modules substitute for the C0x.OBJ modules; they are to be linked
  1721. with DOS applications only, not Windows applications or DLLs.
  1722. These initialization modules are written to alter the memory
  1723. model such that the stack segment is inside the data segment. The
  1724. appropriate C0Fx.OBJ module will be used automatically if you use
  1725. either the -Fs or the -Fm command-line compiler option.
  1726.  
  1727. The -Fc (generate COMDEFs), -Ff (create far variables), -Fs
  1728. (assume DS == SS in all models), and -Fm (enable all -Fx options)
  1729. command-line compiler options are provided for Microsoft
  1730. compatibility. These options are documented in full in Chapter 5
  1731. of the Borland C++ User's Guide manual.
  1732.  
  1733.  
  1734. Linker
  1735.  
  1736. The Borland C++ linker, TLINK, is invoked automatically from the
  1737. command- line compiler unless the -c compiler option is used.
  1738. Options such as memory model and target (Windows or DOS), are
  1739. passed from the compiler to TLINK; TLINK links the appropriate
  1740. libraries based on the compile options.
  1741.  
  1742. TLINK can be used to build both DOS and Windows programs. See
  1743. Chapter 4 in the Borland C++ Tools & Utilities Guide manual for
  1744. material on module definition file statements.
  1745.  
  1746. The following table compares TLINK and LINK options. Note that
  1747. Borland C++ TLINK options are case-sensitive, while Microsoft
  1748. LINK options are not.
  1749.  
  1750. LINK and TLINK options compared
  1751. Microsoft C    Borland C++
  1752. Link option   TLINK option    What it does
  1753.  
  1754. N/A           /3              Enable 32-bit processing.
  1755. /A:size       /A=nnnn         Specify segment alignment
  1756.                               for Windows images.
  1757. /BA           N/A             BATCH. Suppresses prompts
  1758.                               for library or object files
  1759.                               not found.
  1760. N/A           /C              Treat EXPORTS and
  1761.                               IMPORTS section of module
  1762.                               definition file as case
  1763.                               sensitive.
  1764. /CO           /v              Include full symbolic debug
  1765.                               information.
  1766. /CP:bytes     N/A             Sets the program's maximum
  1767.                               memory allocation to 'bytes'.
  1768. N/A           /d              Warn if duplicate symbols in
  1769.                               libraries.
  1770. /DOSSEG    (See comment)      For assembly programs,
  1771.                               forces a certain ordering of
  1772.                               segments in executable. To
  1773.                               enable DOSSEG for an
  1774.                               assembly program, include
  1775.                               DOSSEG in the source code.
  1776. /DS          N/A              For assembly programs, tells
  1777.                               linker to load data starting
  1778.                               at high end of DS instead of
  1779.                               low end.
  1780. /E           N/A              Packs the executable by
  1781.                               removing repeated series of
  1782.                               bytes.
  1783. /F       By default           For LINK, tells linker to
  1784.                               optimize far calls to
  1785.                               procedures in same segment
  1786.                               as caller. (Used with MS
  1787.                               /PACKCODE option.) For
  1788.                               TLINK optimizes far calls
  1789.                               automatically.
  1790. /HE          /?               Provides help on
  1791.                               command-line options.
  1792. /HI         N/A               For real-mode assembly
  1793.                               programs, places executable
  1794.                               as high in memory as possible.
  1795. N/A         /i                Initialize all segments.
  1796. /INC        N/A               Prepares for ILINK.
  1797. /INF        N/A               Tells LINK to display link
  1798.                               information while in process.
  1799. N/A        /Lpaths            Specify library search paths.
  1800. /LI        /l                 Include source line numbers
  1801.                               and associated addresses in
  1802.                               map file.
  1803. /M          /m                Create map file with public
  1804.                               global symbols.
  1805. /NOD [:name] /n               Don't use default libraries.
  1806. /NOE         /e               Ignore Extended Dictionary.
  1807. /NOF        N/A               Turns off far call
  1808.                               translation (see /F option)
  1809. /NOI        /c                Treat case as significant
  1810.                               in symbols.
  1811. /NOL        N/A               Suppress banner
  1812. /NON        N/A               Arrange segments in
  1813.                               executable in the same
  1814.                               order as they are arranged
  1815.                               by /DOSSEG.
  1816. /NOP       /P-                Turn off code packing.
  1817. N/A        /o                 Overlay following modules or
  1818.                               libraries. Microsoft LINK
  1819.                               uses parentheses around
  1820.                               files to be overlaid. (Note
  1821.                               that the overlay scheme is
  1822.                               different between products.)
  1823. /O:number  N/A                Set interrupt 'number' for
  1824.                               passing control to overlays
  1825.                               (other than the default 63).
  1826. /PACKC[:n] /P=n               Pack code segments. 'n'
  1827.                               specifies maximum size
  1828.                               of groups formed by
  1829. /PACKC or /P.
  1830. /PACKD[:n]    N/A             Pack data segments. 'n'
  1831.                               specifies maximum size of
  1832.                               groups formed by /PACKD.
  1833. /PADC:size    N/A             Tells LINK to pad code
  1834.                               module for ILINK by
  1835.                               'size' bytes.
  1836. /PADD:size    N/A             Tells LINK to pad data
  1837.                               segments by 'size' bytes.
  1838. /PAU          N/A             Pauses linking.
  1839. /PM:type      N/A             Sets window type for
  1840.                               Presentation Manager.
  1841.  /Q           N/A             Produces Quick library.
  1842.  N/A /s                       Create detailed map of
  1843.                               segments.
  1844.  /SE:number   N/A             Sets maximum number of
  1845.                               segments allowed.
  1846.  /ST:number   N/A             Sets stack size.
  1847.  /T           /t              Produce .COM files.
  1848.  N/A          /Td             Create target DOS
  1849.                               executable.
  1850. N/A           /Tdc            Create target DOS .COM file.
  1851. N/A           /Tde            Create target DOS .EXE file.
  1852. N/A           /Tw             Create target Windows
  1853.                               executable (.DLL or .EXE).
  1854. N/A           /Twe            Create target Windows
  1855.                               application (.EXE).
  1856. N/A           /Twd            Create target Windows DLL
  1857.                               (.DLL).
  1858. /W            N/A             Warn fixups.
  1859. N/A           /x              Don't create map file.
  1860. N/A           /ye             Use expanded memory for
  1861.                               swapping.
  1862. N/A           /yx             Use extended memory for
  1863.                               swapping.
  1864.  
  1865.  
  1866.  
  1867.        Converting Microsoft DOS Graphics Functions
  1868.  
  1869. The differences between the Microsoft C6.0a DOS graphics system
  1870. and the Borland Graphics Interface are summarized for your
  1871. reference below.
  1872.  
  1873. Two sample programs, MSCGRF.C and BGIGRF.C, provide you with a 
  1874. comparison between Microsoft C6.0a and Borland C++ graphics. You
  1875. will find them helpful as a reference as you convert Microsoft C
  1876. graphics programs to run with the Borland C++ BGI. These programs
  1877. are available for download (see the appendix for more details).
  1878.  
  1879.  
  1880. Supported Graphics Adapters
  1881.  
  1882. Microsoft C6.0a is a closed-ended graphics system that supports a
  1883. limited set of graphics cards. There is no public specification
  1884. from Microsoft explaining how to add support for other graphics
  1885. drivers.  Graphics adapters recognized automatically by Microsoft
  1886. C6.0a graphics are Video Graphics Array (VGA), Extended Graphics
  1887. Adapter (EGA), Color Graphics Adapter (CGA), Multicolor Graphics
  1888. Array (MCGA), and the Olivetti/AT&T variations of the first three
  1889. standards.
  1890.  
  1891. In addition, if you run the Microsoft-supplied
  1892. terminate-and-stay-resident (TSR) program, MSHERC, Microsoft's
  1893. graphics recognizes and supports video adapters compatible with
  1894. the Hercules monochrome graphics hardware specification. If you
  1895. develop software for use by others, you must require your users
  1896. to run MSHERC before running your Microsoft C graphics programs
  1897. with a Hercules monochrome graphics adapter. MSHERC occupies
  1898. nearly 7K bytes of memory, and cannot be removed from memory once
  1899. installed.
  1900.  
  1901. The Microsoft C _getvideoconfig function returns information
  1902. about the current graphics adapter, and the _setvideomode
  1903. function sets up the adapter in an appropriate graphics mode.
  1904.  
  1905. The Borland Graphics Interface (BGI) is an open-ended graphics
  1906. system that supports industry standard graphics adapters.
  1907. Available from Borland is a specification that describes the BGI
  1908. and how to develop third-party BGI graphics drivers. The BGI
  1909. automatically recognizes and supports VGA, EGA, CGA, IBM PC 3270,
  1910. Olivetti/AT&T CGA, and Hercules monochrome graphics adapters. If
  1911. an IBM 8514 Application Interface (AI) TSR is installed on a PC
  1912. with an IBM 8514 or compatible graphics adapter, the BGI
  1913. recognizes and supports this device, in conformance with IBM's
  1914. recommendations for 8514 programming.
  1915.  
  1916. In addition to the BGI graphics drivers supplied with Borland C++
  1917. 3.0, third-party BGI drivers have been developed to support
  1918. various VGA chip sets operating in Super VGA graphics modes that
  1919. offer higher resolution and/or more colors than standard VGA. The
  1920. Borland CompuServe Forum always contains information about
  1921. currently available BGI drivers.
  1922.  
  1923. With Borland C++, the initgraph function loads a graphics driver
  1924. from disk and puts the graphics system into graphics mode. It is
  1925. generally the first BGI function that your program calls. You may
  1926. also use the detectgraph function to override the graphics mode
  1927. selected by initgraph.
  1928.  
  1929. If you or users of your software have a third-party BGI graphics
  1930. driver available, your program would first use the
  1931. registerbgidriver function to register it for use by BGI, and
  1932. then call initgraph.
  1933.  
  1934. Make sure that your program can access the BGI drivers that it
  1935. needs to use. The third argument to the initgraph function gives
  1936. the path where your program finds all of the BGI drivers it can
  1937. use. Relying on just the initgraph function is the simplest for
  1938. you to program, but it may complicate the installation of your
  1939. software.
  1940.  
  1941. You may also add BGI drivers to the GRAPHICS.LIB library supplied
  1942. with Borland C++, link them into your program, then register them
  1943. for use by your program with the registerbgidriver function.
  1944. These steps simplify installation of your software, but add to
  1945. the amount of memory required by your program. See the on-line
  1946. help in the IDE and the documentation file UTIL.DOC for more
  1947. information about this treatment of BGI drivers.
  1948.  
  1949.  
  1950.  
  1951. Displaying Fonts
  1952.  
  1953. Microsoft C6.0a provides two types of graphics fonts, fixed
  1954. height bitmapped fonts and scalable vector fonts. It also has
  1955. special functions to display the built-in video BIOS bitmapped
  1956. font for the current graphics mode. Microsoft graphics manages
  1957. the BIOS font differently than the graphics fonts.
  1958.  
  1959. The Microsoft bitmapped fonts are in three typeface families:
  1960. fixed width Courier, sans serif proportional Helv, and serif
  1961. proportional Times Roman. The scalable vector fonts are Modern, a
  1962. narrow sans serif proportional font; Script, a handwriting-like
  1963. font; and Roman, a Times Roman look-alike.
  1964.  
  1965. The Microsoft bitmapped fonts cannot be resized. If you want to
  1966. use a specific bitmapped font, it is best if your program builds
  1967. a table of available fonts and their characteristics obtained by
  1968. calls to the _getfontinfo function. Then it can build a text
  1969. string describing the exact attributes of the required font, and
  1970. select the font with the _setfont function.
  1971.  
  1972. The Microsoft scalable fonts can be displayed at any size. In
  1973. addition, you can display a scalable font at any horizontal to
  1974. vertical ratio.
  1975.  
  1976. The Microsoft C6.0a graphics library does not have any functions
  1977. to justify text at the left, center, right, top, middle, or
  1978. bottom of a rectangular area. As a consequence, your program must
  1979. manage each step of the process: calculation of text width and
  1980. height, status of justification attributes, computation of
  1981. starting x-y text coordinate including justification, and,
  1982. finally, the actual display of the text.
  1983.  
  1984. To use Microsoft graphics fonts, your program must read them from
  1985. the directory passed to the _registerfonts function.
  1986.  
  1987. Borland C++ includes eleven vector fonts of the sans serif,
  1988. serif, and ornamental varieties.  The default font is an 8x8
  1989. pixel sans serif font that can be resized in integral multiples
  1990. of 8 pixels using the settextsize function. You can resize all of
  1991. the other fonts to various sizes by using the settextsize
  1992. function. You can establish the horizontal-vertical ratio for
  1993. displaying text with the setusercharsize function. The default
  1994. horizontal-vertical ratio is one-to-one (1:1).
  1995.  
  1996. The Borland C++ settextjustify function sets up the rules used to
  1997. justify text. Once set up, text justification is done
  1998. automatically by the outtextxy function with respect to the
  1999. current graphics position.
  2000.  
  2001. To use Borland C++ graphics fonts, your program must read them
  2002. from the same directory in which the BGI drivers are found.
  2003. Alternately, you can link BGI fonts into your program,
  2004. registering and using them much like any BGI drivers you may have
  2005. linked into your program. You can register a font for use by your
  2006. program with the registerbgifont function. See the on-line help
  2007. in the IDE and the documentation file UTIL.DOC for more
  2008. information about treating BGI fonts in this fashion.
  2009.  
  2010. Finally, the Borland C++ 8x8 default font displayed at a 1:1
  2011. horizontal- vertical ratio offers the best fit for replacing the
  2012. built-in BIOS bitmapped font displayed by the Microsoft C6.0a
  2013. functions _outmem and _outtext. Note though that the sizes of the
  2014. BIOS fonts vary: CGA is 8x8, EGA is 8x14, Hercules is 9x14, and
  2015. VGA is 8x16.
  2016.  
  2017.  
  2018.  
  2019. The State of the Graphics System
  2020.  
  2021. Microsoft C6.0a does not have a complete set of function calls to
  2022. determine the current state of the graphics system. As a result,
  2023. you must keep track of the graphics system state yourself in your
  2024. programs, saving old and new state of each graphics attribute
  2025. when you set it. However, the following graphics state
  2026. information is maintained by Microsoft C graphics: x-y
  2027. coordinates, foreground color, background color, fill pattern,
  2028. line pattern, font characteristics, font orientation, and line
  2029. drawing mode.
  2030.  
  2031. Borland C++ has a complete set of function calls to return the
  2032. current state of each attribute in the graphics system. These
  2033. include graphics mode, palette, x-y coordinates, foreground
  2034. color, background color, palette, aspect ratio, fill pattern and
  2035. color, line pattern and color, font characteristics, font
  2036. orientation, and viewport settings.
  2037.  
  2038.  
  2039.  
  2040. Graphics Coordinate Systems
  2041.  
  2042. Microsoft C graphics have three types of functions for displaying
  2043. graphic objects: physical coordinates, viewport coordinates, and
  2044. two types of windowed coordinates. Physical coordinates serve
  2045. only as absolute physical reference points for graphics
  2046. operations; they are not used by any graphics functions that draw
  2047. on the screen.
  2048.  
  2049. Microsoft viewport coordinates are integer x-y values plotted
  2050. with respect to the zero point of the current window, as set with
  2051. the _setviewport function. The _outgtext function displays text
  2052. using the current viewport coordinates.
  2053.  
  2054. Microsoft windowed coordinates are floating point x-y values set
  2055. up with the _setwindow function, and may be positive or negative
  2056. numbers.  Both _setviewport and _setwindow establish the
  2057. rectangular boundaries of a window using the upper left and lower
  2058. right corners of the rectangle. If you use windowed coordinates
  2059. for drawing graphic objects, you must also transform these
  2060. coordinates into viewport coordinates to display text with your
  2061. graph. Use either _getviewcoord_wxy or _getviewcoord_w to do
  2062. this.
  2063.  
  2064. The shape drawing functions draw lines, rectangles, arcs, and
  2065. polygons, get images from the screen, and put images onto the
  2066. screen.  Each function that uses viewpoint coordinates has one or
  2067. two analogous functions in the windowed coordinate system. For
  2068. example, _arc draws an arc with viewport coordinates, while
  2069. _arc_wxy draw an arc in windowed coordinates. The _ellipse
  2070. function draws an ellipse using viewport coordinates, and both
  2071. _ellipse_w and _ellipse_wxy use windowed coordinates. The
  2072. windowed functions with the suffix _w accept coordinate arguments
  2073. with four distinct x-y values, while those with the suffix _wxy
  2074. take structures of x-y coordinate pairs as arguments.
  2075.  
  2076. Microsoft C graphics provides the _getphyscoord, _getviewcoord,
  2077. _getviewcoord_w, _getviewcoord_wxy, and _getwindowcoord functions
  2078. to map from one coordinate system to another, which is required
  2079. uses windowed graphics functions.
  2080.  
  2081. Borland C++ offers a unified view of graphics with a single set
  2082. of functions that all use viewport coordinates as a single frame
  2083. of reference. After the viewport is set, all functions operate
  2084. relative to the zero x-y coordinate of the viewport.
  2085.  
  2086.  
  2087. Other Things You Must Do Differently
  2088.  
  2089. Microsoft C 6.0a graphics has no predefined bitmap patterns for
  2090. filling shapes or drawing lines. You must design and describe
  2091. bitmap patterns in your program before using them. Microsoft C
  2092. graphics also does not have any parameter to control the width of
  2093. lines drawn. In the Microsoft graphics system, if you need to
  2094. draw a line more than one pixel wide, you accomplish this by
  2095. drawing several lines one pixel apart from each other until the
  2096. resulting line is wide enough.
  2097.  
  2098. Borland C++ allows you to use its built-in bitmap patterns to
  2099. fill shapes and to draw lines, and to define and use your own.
  2100. You can also vary the widths of lines drawn by the arc,
  2101. rectangle, pie, drawpoly, line, and linerel, or ellipse
  2102. functions.
  2103.  
  2104. Microsoft C6.0a graphics employs the concept of a bounding
  2105. rectangle, a rectangle drawn so that it contains a drawn ellipse,
  2106. or the ellipse from which a drawn shape is derived. A bounding
  2107. rectangle touches an ellipse or circle at exactly four points,
  2108. the vertices of the figure.  For an arc or pie, the endpoints of
  2109. the drawn shape are marked by lines that intersect the bounding
  2110. rectangle. To draw a curved shape, you need to compute the upper
  2111. left and lower right of corners of its bounding rectangle from
  2112. its center point and radii.
  2113.  
  2114. The Borland C++ graphics system uses a simple and intuitive
  2115. system for drawing curved shapes. You need only to describe the
  2116. center point of the shape in x-y coordinates, and the radii. To
  2117. draw either an arc or pie shape, you also need to specify the
  2118. starting and ending angles of the endpoints, stated in degrees.
  2119.  
  2120. The Microsoft C graphics function _setwritemode controls the
  2121. logical line drawing mode used for _putimage, _lineto, _polygon,
  2122. and _rectangle operations. The manifest constants _GAND, _GOR,
  2123. _GPRESET, _GPSET, and _GXOR provide different ways to combine the
  2124. result of from the current drawing operation with the data
  2125. already on screen. The results are less than intuitive, as shown
  2126. by the pair of graphic programs BGIGRF.C and MSCGRF.C. Borland
  2127. C++ uses logical operators to control only the putimage function.
  2128.  
  2129.  
  2130. A Graphics Reference for Microsoft C Users
  2131.  
  2132. Here is a reference of graphics functions to help you convert
  2133. your Microsoft C graphics programs. BGI contains many other
  2134. useful graphics functions. This reference tabulates the BGI
  2135. functions that most closely correspond to Microsoft C graphics
  2136. functions. They are listed in alphabetic order by category of
  2137. graphics function.
  2138.  
  2139.  
  2140. Graphics System Control
  2141.  
  2142. Microsoft C                 Borland BGI
  2143.  
  2144. _getactivepage              N/A, maintain in your program
  2145. _getvideoconfig             detectgraph, initgraph,
  2146.                             getaspectratio,getpalette,
  2147.                             getmaxx, getmaxy
  2148. _getvisualpage              N/A, maintain in your program
  2149. _setactivepage              setactivepage
  2150. _setvideomode               setgraphmode
  2151. _setvideomoderows           No equivalent, uses BIOS font
  2152. _setvisualpage              setvisualpage
  2153.  
  2154.  
  2155. Drawing & Filling
  2156. Microsoft C              Borland BGI
  2157.  
  2158. _arc                     arc
  2159. _ellipse                 ellipse or fillellipse
  2160. _floodfill               floodfill
  2161. _getarcinfo              getarccoords [arc only]
  2162. _getcurrentposition      getx & gety
  2163. _getcurrentposition_w    No equivalent, remap to viewport
  2164.                          coordinates and use getx and gety
  2165. _getfillmask             getfillpattern
  2166. _getlinestyle            getlinesettings [line style,
  2167.                          pattern, & thickness]
  2168. _getwritemode            N/A
  2169. _lineto                  lineto
  2170. _moveto                  moveto
  2171. _pie                     pieslice
  2172. _polygon                 drawpoly or fillpoly
  2173. _rectangle               rectangle
  2174. _setfillmask             setfillpattern
  2175. _setlinestyle            setlinestyle [line style,
  2176.                          pattern, & thickness]
  2177. _setwritemode            raster operations (ROPS) are
  2178.                          used as arguments to putimage
  2179.  
  2180.  
  2181.  
  2182. Text Output
  2183. Microsoft C              Borland BGI
  2184.  
  2185. _displaycursor           No equivalent, used in text mode
  2186. _getfontinfo             gettextsettings
  2187. _getgtextextent          textwidth
  2188. _getgtextvector          No equivalent, maintain this
  2189.                          information in your program
  2190. _gettextcolor            No equivalent, uses BIOS font
  2191. _gettextcursor           No equivalent, used in text mode
  2192. _gettextposition         No equivalent, uses BIOS font
  2193. _gettextwindow           No equivalent, uses BIOS font
  2194. _outgtext                outtext
  2195. _outmem                  No equivalent, uses BIOS font
  2196. _outtext                 No equivalent, uses BIOS font
  2197. _registerfonts           registerbgifont
  2198. _scrolltextwindow        No equivalent, uses BIOS font
  2199. _setfont                 settextstyle & setusercharsize
  2200. _setgtextvector          settextstyle
  2201. _settextcolor            No equivalent, uses BIOS font
  2202. _settextcursor           No equivalent, used in text mode
  2203. _settextposition         No equivalent, uses BIOS font
  2204. _settextrows             No equivalent, uses BIOS font
  2205. _settextwindow           No equivalent, uses BIOS font
  2206. _unregisterfonts         No equivalent
  2207. _wrapon                  No equivalent, controls word wrap for
  2208.                          _outtext]
  2209.  
  2210.  
  2211. Screen, Viewport & Window
  2212.  
  2213. Microsoft C              Borland BGI
  2214.  
  2215. _clearscreen             cleardevice or clearviewport
  2216. _getimage                getimage
  2217. _getphyscoord            No equivalent,
  2218.                          view(x,y) --> physical (x,y)
  2219. _getpixel                getpixel
  2220. _getviewcoord            No equivalent,
  2221.                          physical (x,y) --> view(x,y)
  2222. _getviewcoord_w          No equivalent,
  2223.                          window (wx,wy) --> view(x,y)
  2224. _getviewcoord_wxy        No equivalent,
  2225.                          window (wx,wy) --> view(x,y)
  2226. _getwindowcoord          No equivalent,
  2227.                          view(x,y) --> window(wx,wy)
  2228. _imagesize               imagesize
  2229. _putimage                putimage
  2230. _setcliprgn              setviewport [also viewport]
  2231. _setpixel                setpixel
  2232. _setvieworg              setviewport [window & clip, too]
  2233. _setviewport             setviewport [also clip]
  2234. _setwindow               Window coordinates are
  2235.                          not available
  2236.  
  2237.  
  2238.  
  2239. Color Control
  2240. Microsoft C              Borland BGI
  2241.  
  2242. _getbkcolor              getbkcolor
  2243. _getcolor                getcolor
  2244. _remappalette            setpalette
  2245. _remapallpalette         setallpalette
  2246. _selectpalette           [Not available, CGA only]
  2247. _setbkcolor              setbkcolor
  2248. _setcolor                setcolor
  2249.  
  2250.  
  2251. State Query & Error Handling
  2252. Microsoft C              Borland BGI
  2253.  
  2254. _grstatus                graphresult & grapherrormsg
  2255.  
  2256.  
  2257.